I am understanding $digest
and $watch
functions. I found that whenever value of model
changes then angular
runs $digest
again and if value of model
changes very frequently then angular
throws infinite loop error.
Ok then, this example throws infinite error
<div ng-repeat="user in getUsers()">{{ user.name }}</div>
...
$scope.getUsers = function() {
return [ { name: 'Hank' }, { name: 'Francisco' } ];
};
BUT this code does not throw any infinite loop
error. Why is it so ? This example should also throw an error
<div> {{getUsers()}}</div>
...
$scope.getUsers = function() {
return [ { name: 'Hank' }, { name: 'Francisco' } ];
};
because as per documentation getUser
function anyways returning a new array everytime in both cases.
Thanks