angularjs - Angular js setInterval -


how can set , intveral in angularjs? want after every 5 seconds data.

my code:

myapp.service('dataservice', function ($http) { this.getdata = function () { //want call function after every 5 sec.    $http({        method: 'get',        url: "http://localhost:8080/api/facereaderdata"    }).success(function (data) {        console.log(data)    });  } });   myapp.controller('maincontroller', function ($scope, dataservice) { $scope.data = null; dataservice.getdata(function (dataresponse) {     $scope.data = dataresponse; }); }); 

thx in advance

i want after every 5 seconds data.

you looking $interval service.

usage follows:

var module = angular.module('dummy.module', []);  module.controller('dummyctrl', ['$scope', '$interval', function ($scope) {      function callback() {         console.dir('called every 5 seconds');     }      $interval(callback, 5000); // callback function called every 5000 milliseconds  }]); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -