Sunday, September 17, 2017

Show the structure of the $interval Service.

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