Answer by Sergey Sahakyan for AngularJS : Prevent error $digest already in...
let $timeoutPromise = null; $timeout.cancel($timeoutPromise); $timeoutPromise = $timeout(() => { $scope.$digest(); }, 0, false);Here is good solution to avoid this error and avoid $applyyou can...
View ArticleAngularJS : Prevent error $digest already in progress when calling...
I'm finding that I need to update my page to my scope manually more and more since building an application in angular. The only way I know of to do this is to call $apply() from the scope of my...
View ArticleAnswer by dnc253 for AngularJS : Prevent error $digest already in progress...
When you get this error, it basically means that it's already in the process of updating your view. You really shouldn't need to call $apply() within your controller. If your view isn't updating as you...
View ArticleAnswer by Lee for AngularJS : Prevent error $digest already in progress when...
Don't use this pattern - This will end up causing more errors than it solves. Even though you think it fixed something, it didn't. You can check if a $digest is already in progress by checking...
View ArticleAnswer by bullgare for AngularJS : Prevent error $digest already in progress...
Sometimes you will still get errors if you use this way (https://stackoverflow.com/a/12859093/801426). Try this: if(! $rootScope.$root.$$phase) { ...
View ArticleAnswer by lambinator for AngularJS : Prevent error $digest already in...
Handy little helper method to keep this process DRY: function safeApply(scope, fn) { (scope.$$phase || scope.$root.$$phase) ? fn() : scope.$apply(fn); }
View ArticleAnswer by frosty for AngularJS : Prevent error $digest already in progress...
The digest cycle is a synchronous call. It won't yield control to the browser's event loop until it is done. There are a few ways to deal with this. The easiest way to deal with this is to use the...
View ArticleAnswer by teleclimber for AngularJS : Prevent error $digest already in...
I have been able to solve this problem by calling $eval instead of $apply in places where I know that the $digest function will be running. According to the docs, $apply basically does this: function...
View ArticleAnswer by Ciul for AngularJS : Prevent error $digest already in progress when...
I had the same problem with third parties scripts like CodeMirror for example and Krpano, and even using safeApply methods mentioned here haven't solved the error for me. But what do has solved it is...
View ArticleAnswer by CMCDragonkai for AngularJS : Prevent error $digest already in...
You can also use evalAsync. It will run sometime after digest has finished! scope.evalAsync(function(scope){ //use the scope... });
View ArticleAnswer by betaorbust for AngularJS : Prevent error $digest already in...
From a recent discussion with the Angular guys on this very topic: For future-proofing reasons, you should not use $$phase When pressed for the "right" way to do it, the answer is currently...
View ArticleAnswer by RNobel for AngularJS : Prevent error $digest already in progress...
yearofmoo did a great job at creating a reusable $safeApply function for us : https://github.com/yearofmoo/AngularJS-Scope.SafeApply Usage : //use by itself $scope.$safeApply(); //tell it which scope...
View ArticleAnswer by SimplGy for AngularJS : Prevent error $digest already in progress...
Understanding that the Angular documents call checking the $$phase an anti-pattern, I tried to get $timeout and _.defer to work. The timeout and deferred methods create a flash of unparsed {{myVar}}...
View ArticleAnswer by nelsonomuto for AngularJS : Prevent error $digest already in...
I would advise you to use a custom event rather than triggering a digest cycle. I've come to find that broadcasting custom events and registering listeners for this events is a good solution for...
View ArticleAnswer by Trevor for AngularJS : Prevent error $digest already in progress...
See http://docs.angularjs.org/error/$rootScope:inprog The problem arises when you have a call to $apply that is sometimes run asynchronously outside of Angular code (when $apply should be used) and...
View ArticleAnswer by Warren Davis for AngularJS : Prevent error $digest already in...
Found this: https://coderwall.com/p/ngisma where Nathan Walker (near bottom of page) suggests a decorator in $rootScope to create func 'safeApply', code: yourAwesomeModule.config([ '$provide',...
View ArticleAnswer by floribon for AngularJS : Prevent error $digest already in progress...
Many of the answers here contain good advices but can also lead to confusion. Simply using $timeout is not the best nor the right solution. Also, be sure to read that if you are concerned by...
View ArticleAnswer by Luc for AngularJS : Prevent error $digest already in progress when...
You should use $evalAsync or $timeout according to the context. This is a link with a good explanation: http://www.bennadel.com/blog/2605-scope-evalasync-vs-timeout-in-angularjs.htm
View ArticleAnswer by Warlock for AngularJS : Prevent error $digest already in progress...
The shortest form of safe $apply is: $timeout(angular.noop)
View ArticleAnswer by user4536971 for AngularJS : Prevent error $digest already in...
This will be solve your problem: if(!$scope.$$phase) { //TODO }
View Article