0
votes

Hi I am getting this error :

https://docs.angularjs.org/error/$rootScope/infdig?p0=10&p1=%5B%5B%22fn:%20parentValueWatch;%20newVal:%201;%20oldVal:%20undefined%22,%22inputValue;%20newVal:%201;%20oldVal:%20undefined%22%5D,%5B%22fn:%20parentValueWatch;%20newVal:%20undefined;%20oldVal:%201%22,%22inputValue;%20newVal:%20undefined;%20oldVal:%201%22%5D,%5B%22fn:%20parentValueWatch;%20newVal:%201;%20oldVal:%20undefined%22,%22inputValue;%20newVal:%201;%20oldVal:%20undefined%22%5D,%5B%22fn:%20parentValueWatch;%20newVal:%20undefined;%20oldVal:%201%22,%22inputValue;%20newVal:%20undefined;%20oldVal:%201%22%5D,%5B%22fn:%20parentValueWatch;%20newVal:%201;%20oldVal:%20undefined%22,%22inputValue;%20newVal:%201;%20oldVal:%20undefined%22%5D%5D

Error: $rootScope:infdig Infinite $digest Loop

10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [["fn: parentValueWatch; newVal: 1; oldVal: undefined","inputValue; newVal: 1; oldVal: undefined"],["fn: parentValueWatch; newVal: undefined; oldVal: 1","inputValue; newVal: undefined; oldVal: 1"],["fn: parentValueWatch; newVal: 1; oldVal: undefined","inputValue; newVal: 1; oldVal: undefined"],["fn: parentValueWatch; newVal: undefined; oldVal: 1","inputValue; newVal: undefined; oldVal: 1"],["fn: parentValueWatch; newVal: 1; oldVal: undefined","inputValue; newVal: 1; oldVal: undefined"]]

I am having tough time recognizing this issue on which watcher or why suddenly it's throwing error. it was working fine before yesterday.

Any help is much appreciated.

1
Can you create jsfiddle/plunker demo - Tushar
you are watching a variable and changing the value of that variable in same watch function/. - ngLover
At least add your code here :) - squiroid
it's impossible to tell you how to fix this error without seeing the code that is causing it, but this error is normally caused by a faulty filter. - Claies

1 Answers

4
votes

Description This error occurs when the application's model becomes unstable and each $digest cycle triggers a state change and subsequent $digest cycle. Angular detects this situation and prevents an infinite loop from causing the browser to become unresponsive.

For example, the situation can occur by setting up a watch on a path and subsequently updating the same path when the value changes.

$scope.$watch('foo', function() {
  $scope.foo = $scope.foo + 1;
});

One common mistake is binding to a function which generates a new array every time it is called. For example:

<div ng-repeat="user in getUsers()">{{ user.name }}</div>

...

$scope.getUsers = function() {
  return [ { name: 'Hank' }, { name: 'Francisco' } ];
};

Since getUsers() returns a new array, Angular determines that the model is different on each $digest cycle, resulting in the error. The solution is to return the same array object if the elements have not changed:

var users = [ { name: 'Hank' }, { name: 'Francisco' } ];

$scope.getUsers = function() {
  return users;
};

The maximum number of allowed iterations of the $digest cycle is controlled via TTL setting which can be configured via $rootScopeProvider.

visit for more info https://docs.angularjs.org/error/$rootScope/infdig