码迷,mamicode.com
首页 > Web开发 > 详细

angularJs-clock

时间:2018-10-14 21:55:06      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:time   oct   control   isp   pen   cti   1.4   https   alt   

 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>
View Code

 

angularJs-clock

标签:time   oct   control   isp   pen   cti   1.4   https   alt   

原文地址:https://www.cnblogs.com/johnhery/p/9787990.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!