angularjsng-idle

Change idle duration at runtime in AngularJS Ng-Idle


I am using ng-idle to detect inactivity.

The idleDuration is set like so:

.config(function($idleProvider, $keepaliveProvider) {
            // configure $idle settings
            $idleProvider.idleDuration(5); // in seconds
            $idleProvider.warningDuration(5); // in seconds
            $keepaliveProvider.interval(2); // in seconds
        })

How can I change it at runtime in a controller or in a service?

It is possible to inject the $idle service like so:

.controller('EventsCtrl', function($scope, $idle)

Unforunately $idle does not have a property for changing the idleDuration.


Solution

  • As per v1.0.0, Idle.setIdle() can change the configuration value at any time.