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
Post a Comment