How to deep watch an array in angularjs?

There is an array of objects in my scope, I want to watch all the values of each object. This is my code: function TodoCtrl($scope) { $scope.columns = [ { field:’title’, displayName: ‘TITLE’}, { field: ‘content’, displayName: ‘CONTENT’ } ]; $scope.$watch(‘columns’, function(newVal) { alert(‘columns changed’); }); } But when I modify the values, e.g. I … Read more

AngularJS : How to watch service variables?

I have a service, say: factory(‘aService’, [‘$rootScope’, ‘$resource’, function ($rootScope, $resource) { var service = { foo: [] }; return service; }]); And I would like to use foo to control a list that is rendered in HTML: <div ng-controller=”FooCtrl”> <div ng-repeat=”item in foo”>{{ item }}</div> </div> In order for the controller to detect when … Read more