angularJs-clock
Posted 啦啦啦-小菜分享
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了angularJs-clock相关的知识,希望对你有一定的参考价值。
1 <!DOCTYPE html> 2 <html lang="en" ng-app="myClock"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>angularJs-clock</title> 6 <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> 7 </head> 8 <body> 9 <div ng-app ng-controller="MyController"> 10 <h1>现在时间是:<span ng-bind="clock"></span></h1> 11 </div> 12 </body> 13 <script> 14 angular.module(‘myClock‘,[]) 15 .controller(‘MyController‘, function($scope,$timeout){ 16 var updateClock = function(){ 17 $scope.clock = new Date(); 18 } 19 updateClock(); 20 } 21 ) 22 </script> 23 </html>
1 <!DOCTYPE html> 2 <html lang="en" ng-app="myClock"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>angularJs-clock</title> 6 <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> 7 </head> 8 <body> 9 <div ng-app ng-controller="MyController"> 10 <h1>现在时间是:<span ng-bind="clock.fulldate"></span></h1> 11 </div> 12 </body> 13 <script> 14 angular.module(‘myClock‘,[]) 15 .controller(‘MyController‘, function($scope){ 16 $scope.clock = {}; 17 var updateClock = function(){ 18 $scope.clock.now = new Date(); 19 $scope.clock.fulldate = new Date().getFullYear()+"-"+(new Date().getMonth()+1)+"-"+new Date().getDate()+" "+new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds() 20 } 21 setInterval(function(){ 22 $scope.$apply(updateClock); 23 },1000) 24 updateClock(); 25 } 26 ) 27 </script> 28 </html>
以上是关于angularJs-clock的主要内容,如果未能解决你的问题,请参考以下文章