I am using two controller in same page.
First Controller has the Two tabs. First Tab has contact list and second tab has Favourites List.
In First Tab. I am showing all the datas. In second Tab, I have showing datas based on isFavourites field
ng-show="user.isFavourites"
If it is true. it is showing.
When i clicking the contact list on First Tab. Popup Will show. In that popup, I have one button that is AddFav. Popup is a second Controller.
When i clicking on AddFav button I have setting isFavourites is true.
So my question is
After setting isFavourites, When i goto the second tab, The data will show with last updated Filed.
My Form is
<div id="userListControl">
<div id="tab1">...</div>
<div id="tab2">...</div>
</div>
<div id="userDetailsControl">
</div>
userDirectory.controller("userListControl", function($scope,$rootScope, $http)
{
$http.get('data/userData.json').success (function(data){
$scope.users = data;
});
$scope.selectUser = function(user){
$rootScope.selectedUser = user;
showPopup();
}
});
});
// Contact Details Controller with Watch()
userDirectory.controller("userDetailsControl", function($scope, $rootScope){
$rootScope.$watch("selectedUser", function(newVal){
$scope.user = newVal;
});
$scope.addFav = function(user){
$rootScope.selectedUser.isFavourites = true;
console.log($rootScope.selectedUser)
}
});
In first control, Selectuser is used for when clicking on contact list, It will shows that data in popup