To view the $scope.$watch variable of a $scope.$watch objectEquality with objectEquality set to true OR $scope.$watchCollection better?
For a $scope object variable (e.g. 15 attributes, some nested 2 levels in depth) updated with input elements and ng-model in the view, how bad is $scope.$watch with objectEquality set to true ? Is this a big thing to avoid?
Is $watchCollection best solution?
I am looking for easy wins to improve the performance of my AngularJS application (I still adhere to v1.2.2).
// ctrl scope var $scope.filters = { name: '', info: {test: '', foo: '', bar: ''}, yep: '' // etc ... } // ctrl watch ? $scope.$watch('filters', function(newVal, oldVal) { if(newVal !== oldVal) { // call with updated filters } }, true); // or ctrl watch collection ? $scope.$watchCollection('filters', function(newVal, oldVal) { if(newVal !== oldVal) { // call with updated filters } }); // view input with ng-model <input type="text" ng-model="filters.name" /> <input type="text" ng-model="filters.info.test" /> <input type="text" ng-model="filters.yep" /> // etc ...
angularjs angularjs-scope angularjs-watch
wbeange Oct 23 '14 at 19:00 2014-10-23 19:00
source share