<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <script type="text/javascript" src="angular-1.3.0.js"></script> <title></title> <script> var app = angular.module("timer", []); app.directive("nowTime", function () { return { restrict: "EACM", template: "<h3>" + new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString() + "</h3>", replace: true } }); </script> </head> <body ng-app="timer"> <now-time>当前时间:</now-time> <!-- 标签: restrict: "E" - Element --> <div now-time>当前时间:</div> <!-- 属性: restrict: "A" - Attribute --> <div class="now-time">当前时间:</div> <!-- 类: restrict: "C" --> <!-- directive: now-time --> <!-- 注释: restrict: "M" --> </body> </html>
几种获取当前时间的方法
最新推荐文章于 2024-07-18 11:50:26 发布