The $interval Service
The$interval
service is AngularJS' version of the
window.setInterval
function.Example
Display the time every second:var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $interval) {
$scope.theTime = new Date().toLocaleTimeString();
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
});