HLJ 发布于
2018-08-17 14:24:15

AngularJS定时器

AngularJS定时器
<body>
<div ng-app="myApp" ng-controller="myCtrl" class="ng-cloak">
  当前时间:{{clock | date:'yyyy-MM-dd HH:mm:ss'}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.clock = new Date();
  var updateClock = function() {
    $scope.clock = new Date();
  };
  setInterval(function() {
    $scope.$apply(updateClock);
  }, 1000);
  updateClock();
});
</script>
</body>

当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2018-08-17/120.html
最后生成于 2023-06-18 18:37:24
此内容有帮助 ?
0