-3

I can see below errors in my angular js on IE 10 console I am using angular v1.3.4 . This error occur when I am navigating from one page to another.

Error: [$rootScope:infdig] http://errors.angularjs.org/1.3.4/$rootScope/infdig?p0=10&p1=%5B%5B%7B%22msg%22%3A%22fn%3A%20function(a)%7Bvar%20b%3De(a)%3 .... long string which goes on
   at $digest (http://localhost:9080/WeBoM/js/libs/angular.min.js:123:176)
   at $apply (http://localhost:9080/WeBoM/js/libs/angular.min.js:125:305)
   at m (http://localhost:9080/WeBoM/js/libs/angular.min.js:80:453)
   at N (http://localhost:9080/WeBoM/js/libs/angular.min.js:85:32)
   at onload (http://localhost:9080/WeBoM/js/libs/angular.min.js:86:69)

and after that,

Error: [$rootScope:inprog] http://errors.angularjs.org/1.3.4/$rootScope/inprog?p0=%24apply
   at l (http://localhost:9080/WeBoM/js/libs/angular.min.js:117:213)
   at $apply (http://localhost:9080/WeBoM/js/libs/angular.min.js:125:231)
   at Anonymous function (http://localhost:9080/WeBoM/js/libs/angular.min.js:227:245)
   at handle (http://localhost:9080/WeBoM/js/libs/jquery.min.js:3:12506)
   at dispatch (http://localhost:9080/WeBoM/js/libs/jquery.min.js:3:8493)
   at handle (http://localhost:9080/WeBoM/js/libs/jquery.min.js:3:5177)
teksan
  • 142
  • 13
  • 1
    You are most likely calling `$apply` somewhere in your code which is attempting to restart the digest cycle while a digest cycle is already occurring, since you are navigating from one page to another. That said, without code it's impossible to confirm that. – David L Sep 22 '15 at 14:08
  • I looked up the codebase and yes js files have $scope.$apply(); and scope.$apply(function(){ scope.$parent[attrs.visible] = true; }); code snippets – teksan Sep 22 '15 at 14:13
  • the link in that error explains it for you! ...just follow the link – charlietfl Sep 22 '15 at 14:20
  • possible duplicate of [Prevent error $digest already in progress when calling $scope.$apply()](http://stackoverflow.com/questions/12729122/prevent-error-digest-already-in-progress-when-calling-scope-apply) – teksan Sep 23 '15 at 06:25

1 Answers1

-1

This problem occurred from if using $scope.$apply();

So wherever use it, you need check a condition like !$scope.$$phase before the scope.apply call

if(!$scope.$$phase)
{
$scope.$apply();
}

But don't do if (!$scope.$$phase) $scope.$apply(), it means your $scope.$apply() isn't high enough in the call stack.

My answer only short kind of solutions, You can checkout the more solutions in under this discussion AngularJS : Prevent error $digest already in progress when calling $scope.$apply()

Community
  • 1
  • 1
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
  • 2
    Right in angular github wiki it is documented not to use this approach https://github.com/angular/angular.js/wiki/Anti-Patterns – charlietfl Sep 22 '15 at 14:24
  • `Don't do if (!$scope.$$phase) $scope.$apply(), it means your $scope.$apply() isn't high enough in the call stack.` , that's why am post the previous discussion – Ramesh Rajendran Sep 22 '15 at 14:25
  • @charlietfl, Yupe, He can see the details about it from the link, which I post in my answer :) :+1 – Ramesh Rajendran Sep 22 '15 at 14:27
  • 1
    nothing was mentioned in your answer about it being a discouraged practice and there are other ways to manage it – charlietfl Sep 22 '15 at 14:31
  • This is merely masking the symptom, not addressing the problem, which can't be addressed because the question is too incomplete to correctly answer. – David L Sep 22 '15 at 15:09