angular进行时间展示

来源:互联网 发布:星桥数据 编辑:程序博客网 时间:2024/06/03 16:51

一.在angular中有很多属性方法,一下为大家展示下简单的显示时间的操作

二.代码展示

<!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().toLocaleString()+"</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>


原创粉丝点击