Bug with watch


#1

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!\nWatchers fired in the last 5 iterations: [[\“fn: $locationWatch; newVal: 35; oldVal: 34\”],[\“fn: $locationWatch; newVal: 36; oldVal: 35\”],[\“fn: $locationWatch; newVal: 37; oldVal: 36\”],[\“fn: $locationWatch; newVal: 38; oldVal: 37\”],[\“fn: $locationWatch; newVal: 39; oldVal: 38\”]]\nhttp://errors.angularjs.org/1.2.12/$rootScope/infdig?p0=10&p1=%5B%5B%22fn%3A%20%24locationWatch%3B%20newVal%3A%2035%3B%20oldVal%3A%2034%22%5D%2C%5B%22fn%3A%20%24locationWatch%3B%20newVal%3A%2036%3B%20oldVal%3A%2035%22%5D%2C%5B%22fn%3A%20%24locationWatch%3B%20newVal%3A%2037%3B%20oldVal%3A%2036%22%5D%2C%5B%22fn%3A%20%24locationWatch%3B%20newVal%3A%2038%3B%20oldVal%3A%2037%22%5D%2C%5B%22fn%3A%20%24locationWatch%3B%20newVal%3A%2039%3B%20oldVal%3A%2038%22%5D%5D
at file:///android_asset/www/lib/js/ionic.bundle.js:7548:12
at Scope.$digest (file:///android_asset/www/lib/js/ionic.bundle.js:19339:19)
at Scope.$apply (file:///android_asset/www/lib/js/ionic.bundle.js:19553:24)
at done (file:///android_asset/www/lib/js/ionic.bundle.js:15311:45)
at completeRequest (file:///android_asset/www/lib/js/ionic.bundle.js:15512:7)
at XMLHttpRequest.onreadystatechange (file:///android_asset/www/lib/js/ionic.bundle.js:15455:11)"}"


#2

This is most likely to be your own fault, not a bug with AngularJS. This error is basically saying you have a recursive call to $digest. The most common sources for this are:

  • Modifying a variable X in X’s $watch.
  • Modifying a variable in a ng-init.

Both this cases won’t be a problem if you assign a static value, but if you increment something etc it will create an infinite recursion.


#3

thank you. yes i have in one place code which set value from response. But its only static value… any way will figure out it