Reputation: 163
In AngularJS, is it possible to call a function repeatedly(say every 20 minutes)? I tried $timeout, but the function will be called only once.
Basically I want to pop up a notification dialog every 20 minutes of inactivity.
Upvotes: 0
Views: 4548
Reputation: 125
New version of AngularJS uses $interval for this. See http://docs.angularjs.org/api/ng.$interval
Upvotes: 5
Reputation: 11307
Just call $timeout
again in the function. If this is not possible, write a wrapper function like this:
function wrapper() {
theActualFunction();
$timeout(wrapper, 12345);
}
$timeout(wrapper, 12345);
Upvotes: 1