脚本宝典收集整理的这篇文章主要介绍了js实例教程-AngularJS:helloworld显示当前时间的案例,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。
<!DOCTYPE htML> <html ng-app="app"> <head> <meta charset="utf-8" /> <tITle>Angular JS Hello World!</title> <script src="https://cdn.static.runoob.COM/libs/Angular.js/1.4.6/angular.min.js"></script> </head> <body> <p ng-controller="mainController"> <h1>Hello {{ message }}</h1> </p> <p ng-controller="myController"> <h1>当前时间 : <font color="orangered">{{ clock }}</font></h1> </p> </body> <script> VAR myApp = angular.module('app', []); myApp.controller('mainController', function($scope) { $scope.message = "Plunker"; }); myApp.controller('myController', function($scope, $timeout) { var updateClock = function() { var da = new Date(); var year = da.getFullYear()+'年'; var month = da.getMonth()+1+'月'; var dates = da.getDate()+'日'; var now = year+month+dates; var s = da.getHours()+'时'; var f = da.getMinutes()+'分'; var m = da.getSeconds(); now = now +s+f+m; $scope.clock = now; $timeout(function() { updateClock(); }, 1000); }; updateClock(); }); </script> </html>
<!DOCTYPE html> <html ng-app="app"> <head> <meta charset="utf-8" /> <title>Angular JS Hello World!</title> <script src="https://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body> <p ng-controller="mainController"> <h1>Hello {{ message }}</h1> </p> <p ng-controller="myController"> <h1>当前时间 : <font color="orangered">{{ clock }}</font></h1> </p> </body> <script> var myApp = angular.module('app', []); myApp.controller('mainController', function($scope) { $scope.message = "Plunker"; }); myApp.controller('myController', function($scope, $timeout) { var updateClock = function() { var da = new Date(); var year = da.getFullYear()+'年'; var month = da.getMonth()+1+'月'; var dates = da.getDate()+'日'; var now = year+month+dates; var s = da.getHours()+'时'; var f = da.getMinutes()+'分'; var m = da.getSeconds(); now = now +s+f+m; $scope.clock = now; $timeout(function() { updateClock(); }, 1000); }; updateClock(); }); </script> </html>
觉得可用,就经常来吧!Javascript技巧 脚本宝典 欢迎评论哦! js技巧,巧夺天工,精雕玉琢。小宝典献丑了!
以上是脚本宝典为你收集整理的js实例教程-AngularJS:helloworld显示当前时间的案例全部内容,希望文章能够帮你解决js实例教程-AngularJS:helloworld显示当前时间的案例所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。