user2793135
user2793135

Reputation: 163

angularjs $timeout and repeated calls

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

Answers (2)

Ivo Peterka
Ivo Peterka

Reputation: 125

New version of AngularJS uses $interval for this. See http://docs.angularjs.org/api/ng.$interval

Upvotes: 5

lex82
lex82

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

Related Questions