var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope){
function updateTime(){
var data = new Date();
var houer = data.getHours()<10?"0"+data.getHours():data.getHours();
var minute = data.getMinutes()<10?"0"+data.getMinutes():data.getMinutes();
var second = data.getSeconds()<10?"0"+data.getSeconds():data.getSeconds();
var now = houer + ":" + minute + ":" + second;
$scope.time = now;
setInterval(updateTime, 1000);
}
updateTime();
});
代码我这样子写,有在页面上显示时间,但没有变。这是怎么回事?
Crystal33
相关分类