Coder Social home page Coder Social logo

Comments (4)

karthilxg avatar karthilxg commented on August 19, 2024

I was getting the $digets alrready in progress error, while trying to display the count down timer. Commenting out the $apply does the trick.

$scope.$on('IdleWarn', function(e, countdown) {
          // $scope.$apply(function() {
            $scope.value = countdown;
          // });
        });

Error Stack:
2015-03-19 17:39:57.726angular.js:10126 Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.2.28/$rootScope/inprog?p0=NaNigest
at VALIDITY_STATE_PROPERTY (http://localhost:9000/bower_components/angular/angular.js:78:12)
at beginPhase (http://localhost:9000/bower_components/angular/angular.js:13122:15)
at Scope.$get.Scope.$apply (http://localhost:9000/bower_components/angular/angular.js:12908:11)
at http://localhost:9000/bower_components/ng-idle/angular-idle.js:292:18
at Scope.$get.Scope.$broadcast (http://localhost:9000/bower_components/angular/angular.js:13093:28)
at countdown (http://localhost:9000/bower_components/ng-idle/angular-idle.js:174:22)
at Array.deferred.promise.then.wrappedProgressback (http://localhost:9000/bower_components/angular/angular.js:11700:88)
at http://localhost:9000/bower_components/angular/angular.js:11668:28
at Scope.$get.Scope.$eval (http://localhost:9000/bower_components/angular/angular.js:12811:28)
at Scope.$get.Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:12623:31)

from ng-idle.

fracz avatar fracz commented on August 19, 2024

You haven't read my issue carefully - changing scope insite event handling does not work without $apply call. This is also used in the idle-countdown directive.

Library should not force users to call $apply method. When target environment is not known (sometimes inside $digest loop, sometimes not), it may be good idea to implement sth like safe $apply.

It's not a big deal as one can cope with that easily. But I have spent some time investigating why my scope is not refreshed after receiving IdleWarn event.

from ng-idle.

karthilxg avatar karthilxg commented on August 19, 2024

@fracz Thanks !! Using safe apply resolves the issue.

from ng-idle.

moribvndvs avatar moribvndvs commented on August 19, 2024

When I originally laid out this module and looked at the right way to use $broadcast in a module, there was back-and-forth over whether or not broadcasting an event should cause a digest (it does not), with plenty of reasonable arguments from either side. True enough, a number of ng-idle users raised concerns over issues where ng-idle causes digests (specifically that they don't want them).

In either case, it seems the most reasonable way to accommodate everyone is to err on the side of caution, but give people an easy-to-use alternative for those that don't want to apply (the idle-countdown directive).

Solutions to make this work are trivial, so I don't feel compelled to change it unless it seems everyone wants it. I should, however, at least make this issue and the way to resolve it much clearer in the wiki.

from ng-idle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.