想在网页上,做一个显示当前系统时钟。
<body ng-app="App2" ng-controller="Ctrl2"> <div ng-bind="ShowTime"> </div></body>
angularjs程序:
var app = angular.module('App2', []); app.controller('Ctrl2', function ($scope, $interval, $filter) { $scope.Timer = $interval(function () { var time = $filter('date')(new Date(), 'HH:mm:ss'); $scope.ShowTime = time; },1000); });
演示结果: