Chris Chris - 1 year ago 103
AngularJS Question

Call a function every 5 sec angular

I need to get data from my back-end at every 5 secs, I have a http function which returns me the data, but now I need to call another function which invokes the http function on every 5 secs. I'm searching for a solution with Angular.

Answer Source

Put your $http call into a function, and on complete, call it again in 5 seconds:

function getStuff() {
   $http.get().success(function(data) {
       $timeout(getStuff, 5000);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download