在angularjs实现一个时钟
<body ng-app="App2" ng-controller="Ctrl2"> <div ng-bind="ShowTime"> </div> </body>
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); });
演示: