Currently, I have a watch set up in my controller for the following watch:
var pageFunc = $scope.$watch('page["USER"].number', function(newob,oldob){
console.log("WATCHING page");
if(oldob != newob){
//perform data load
}
},true);
The collection that I am observing includes these elements:
page["USER"].number = 20;
page["TESTER"].number = 60;
page["BORROWER"].number = 30;
page["CLIENT"].number = 80;
I am looking to create a single watch that can track changes in all elements within this collection.
I attempted the following approach:
$scope.$watch('page[" '+$scope.selectedType+'"].number', function(newob,oldob)
where $scope.selectedType is initialized inside ng-init. However, this method failed as the watch is triggered before ng-init runs. What would be the most effective way to accomplish this?