Reputation: 313
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
Upvotes: 1
Views: 543
Reputation: 8086
Use Angular's $timeout service:
$timeout(function() {
$scope.$apply();
});
This will automatically wait for the current digest cycle to complete before calling $apply.
Upvotes: 1