AngularJs显示当前时间
来源:互联网 发布:win10不信任软件 编辑:程序博客网 时间:2024/05/16 14:24
testdrective3.html
<span style="font-size:14px;"><!DOCTYPE html><html ng-app="time"> <head> <script src="../js/angular.js"></script> <script src="directive3.js"></script> </head> <body> <!-- 显示当前时间 --> <div ng-controller="Ctrl2"> Date format: <input ng-model="format"> <hr/> Current time is: <span my-current-time="format"></span> </div> </body></html></span>directive3.js
<span style="font-size:14px;">var time = angular.module('time', []) // Register the 'myCurrentTime' directive factory method. // We inject $timeout and dateFilter service since the factory method is DI. .directive('myCurrentTime', function($timeout, dateFilter) { // return the directive link function. (compile function not needed) return function(scope, element, attrs) { var format, // date format timeoutId; // timeoutId, so that we can cancel the time updates // used to update the UI function updateTime() { element.text(dateFilter(new Date(), format)); } // watch the expression, and update the UI on change. scope.$watch(attrs.myCurrentTime, function(value) { format = value; updateTime(); }); // schedule update in one second function updateLater() { // save the timeoutId for canceling timeoutId = $timeout(function() { updateTime(); // update DOM updateLater(); // schedule another update }, 1000); } // listen on DOM destroy (removal) event, and cancel the next UI update // to prevent updating time ofter the DOM element was removed. element.bind('$destroy', function() { $timeout.cancel(timeoutId); }); updateLater(); // kick off the UI update process. } });time.controller('Ctrl2',function($scope){$scope.format = 'yyyy-MM-dd h:mm:ss';});</span>
0 0
- AngularJs显示当前时间
- HTML5之AngularJS实现当前时间显示
- 当前时间显示
- 显示当前时间
- JavaScript显示当前时间
- 显示当前系统时间
- 完整显示当前时间
- 显示当前时间
- 网页显示当前时间
- 显示当前时间
- js显示当前时间
- ios 显示当前时间
- javascript 显示当前时间
- flex 显示当前时间
- jquery显示当前时间
- js 显示当前时间
- tkinter显示当前时间
- 显示当前时间
- FD_set FD_zero
- Eclipse开发环境导入android sdk的sample中API Demos
- 平安的互联网布局新探索 平安天下通引领金融服务再升级
- FAQ: OPEN INTERFACES - ASN Transactions (Doc ID 225233.1)
- AlphaControls9.10FullSource xe7个人修改版加原源码
- AngularJs显示当前时间
- hadoop日志输出
- linux 查看进程和终止进程
- 曾经的黑帮老大,现在的Java大神,你有什么要问的?
- linux c语言 select函数用法
- Android -- Camera2(Android5.0)
- 师文汇-OceanBase-支付宝交易O2O最佳实践
- list remove
- Almediadev VCL for Delphi XE 7