1

An error occurs when you call $digest or apply

  registerAjax = ->
    successRegister = ->
      $scope.showRegistrationPanel = false
      $scope.showEndRegistrationPanel = true
      $scope.$digest()
   errorRegister = (response) ->
      $scope.textErrorPanelRegistration = response.data.error
      $scope.showErrorPanel = true
      $scope.$apply()



   data =
     password: $scope.user.password
     firstName: $scope.user.firstName
    lastName: $scope.user.lastName
    email: $scope.user.email

   http.post REGISTER_URL, data
    .then successRegister, errorRegister

when calling $digest or $apply the error takes off but it all works

Error: [$rootScope:inprog] http://errors.angularjs.org/1.4.7/$rootScope/inprog?p0=%24digest
at Error (native)
at http://localhost:8000/lib/angular/angular.min.js?M420gm3LwzcQLAcaXrk6IQ:6:416
2
  • Are you using jQuery.ajax in your code..then obviously you need to run digest cycle..or you could just try $timeout(function(){}) for running safe digest cycle Commented Dec 13, 2015 at 15:02
  • So there is no need to run digest cycle..if you are using $http methods to make ajax. Commented Dec 13, 2015 at 15:07

1 Answer 1

1

Use Angular's $timeout service:

$timeout(function() {
  $scope.$apply();
});

This will automatically wait for the current digest cycle to complete before calling $apply.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.