10 $ digest () iterations reached error in ionic (angular)

I am writing my first app in angularjs and this is giving me error

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D
    at ionic.bundle.js:8890
    at Scope.$digest (ionic.bundle.js:23108)
    at Scope.$apply (ionic.bundle.js:23333)
    at bootstrapApply (ionic.bundle.js:10275)
    at Object.invoke (ionic.bundle.js:13012)
    at doBootstrap (ionic.bundle.js:10273)
    at bootstrap (ionic.bundle.js:10293)
    at angularInit (ionic.bundle.js:10187)
    at ionic.bundle.js:34952
    at HTMLDocument.trigger (ionic.bundle.js:11571)(anonymous function) @ ionic.bundle.js:20434
ionic.bundle.js:23336 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D
ionic.bundle.js:20434 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D
    at ionic.bundle.js:8890
    at Scope.$digest (ionic.bundle.js:23108)
    at Scope.$apply (ionic.bundle.js:23333)
    at done (ionic.bundle.js:18486)
    at completeRequest (ionic.bundle.js:18676)
    at XMLHttpRequest.requestLoaded (ionic.bundle.js:18617)(anonymous function) @ ionic.bundle.js:20434
ionic.bundle.js:23336 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

      

My app.js application code

run(function ($rootScope, $state, AuthService, AUTH_EVENTS) {
  $rootScope.$on('$stateChangeStart', function (event,next, nextParams, fromState) {

    if (!AuthService.isAuthenticated()) {
      if (next.name !== 'app.login') {
        event.preventDefault();
        $state.go('app.login');
      }
    }
  });
});

      

If I remove the last part of the user redirecting to the login page if it is not authenticated, I don't get the error. During boot it does get into a loop several times if I start with

domain.com/ 

      

Why is this happening?

+3


source to share





All Articles