Tuesday, January 30, 2018

write a program for interval service in angularJS.

The Interval service is AngularJS version of the window.setInterval function.

Program

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="abc" ng-controller="def"> 
<h1>{{theTime}}</h1>
</div>
<script>
var app = angular.module('abc', []);
app.controller('def', function($scope, $interval)
{
  $scope.theTime = new Date().toLocaleTimeString();
  $interval(function () 
  {
      $scope.theTime = new Date().toLocaleTimeString();
  }, 1000);
});
</script>
</body>
</html>

Output



0 comments:

Post a Comment

Thanks For Commented.

TechTalk