Reputation: 894
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
.
Upvotes: 2
Views: 4259
Reputation: 2528
I know i'm answering late...
In older versions v1.0.0 Idle time cannot be change at the run-time, once it is initialized using IdleProvider.idle(seconds).
But in version v1.0.0 he provided new api to change config value at rum-time using Idle.setIdle(seconds)
Note: Seconds should be integer value. By default Idle time will be 20 mins
Refernce https://github.com/HackedByChinese/ng-idle/wiki/Idle-and-Idleprovider
Upvotes: 1
Reputation: 42497
As per v1.0.0, Idle.setIdle()
can change the configuration value at any time.
Upvotes: 1