x
 
<!DOCTYPE html>
<html>
<script src="https://cdn.staticfile.net/angular.js/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl"> 
<p>当前时间是:</p>
<h1>{{theTime}}</h1>
</div>
<p>$interval 服务每隔指定的毫秒数运行一次函数。</p>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $interval) {
  $scope.theTime = new Date().toLocaleTimeString(); // 初始化时间为当前本地时间字符串
  $interval(function () {
      $scope.theTime = new Date().toLocaleTimeString(); // 每秒更新一次时间为当前本地时间字符串
  }, 1000);
});
</script>
</body>
</html>