Quantcast
Channel: AngularJS : Prevent error $digest already in progress when calling $scope.$apply() - Stack Overflow
Browsing all 29 articles
Browse latest View live
↧

Answer by Sachin Mishra for AngularJS : Prevent error $digest already in...

The issue is basically coming when, we are requesting to angular to run the digest cycle even though its in process which is creating issue to angular to understanding. consequence exception in...

View Article


Answer by cepix for AngularJS : Prevent error $digest already in progress...

When I disabled debugger , the error is not happening anymore. In my case, it was because of debugger stopping the code execution.

View Article


Answer by Eduardo Eljaiek for AngularJS : Prevent error $digest already in...

try using $scope.applyAsync(function() { // your code }); instead of if(!$scope.$$phase) { //$digest or $apply } $applyAsync Schedule the invocation of $apply to occur at a later time. This can be used...

View Article

Answer by Sagar M for AngularJS : Prevent error $digest already in progress...

First of all, don’t fix it this way if ( ! $scope.$$phase) { $scope.$apply(); } It does not make sense because $phase is just a boolean flag for the $digest cycle, so your $apply() sometimes won’t run....

View Article

Answer by Satish Singh for AngularJS : Prevent error $digest already in...

You can use $timeout to prevent the error. $timeout(function () { var scope = angular.element($("#myController")).scope(); scope.myMethod(); scope.$scope(); },1);

View Article


Answer by Ashu for AngularJS : Prevent error $digest already in progress when...

I have been using this method and it seems to work perfectly fine. This just waits for the time the cycle has finished and then triggers apply(). Simply call the function apply(<your scope>) from...

View Article

Answer by Shawn Dotey for AngularJS : Prevent error $digest already in...

similar to answers above but this has worked faithfully for me... in a service add: //sometimes you need to refresh scope, use this to prevent conflict this.applyAsNeeded = function (scope) { if...

View Article

Answer by ranbuch for AngularJS : Prevent error $digest already in progress...

This is my utils service: angular.module('myApp', []).service('Utils', function Utils($timeout) { var Super = this; this.doWhenReady = function(scope, callback, args) { if(!scope.$$phase) { if (args...

View Article


Answer by Visakh B Sujathan for AngularJS : Prevent error $digest already in...

use $scope.$$phase || $scope.$apply(); instead

View Article


Answer by user4536971 for AngularJS : Prevent error $digest already in...

This will be solve your problem: if(!$scope.$$phase) { //TODO }

View Article

Answer by Warlock for AngularJS : Prevent error $digest already in progress...

The shortest form of safe $apply is: $timeout(angular.noop)

View Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article
Browsing all 29 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>