Chris Chris - 2 months ago 5x
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.


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);