Error! oh noes: Angularjs $digest already in progress.
Generally you shouldn’t be using apply too often in your code, it’s mainly for when your data may have changed from outside angular and you want to update the template with model data.
You can check if a $digest is already in progress by checking $scope.$$phase.
1 2 3 4 5 |
if(!$scope.$$phase) { //$digest or $apply } |
(for fellow googlers) This is considered an anti-pattern : https://github.com/angular/angular.js/wiki/Anti-Patterns
Yep, definite anti-pattern. Please use $timeout() instead.