案例:AngularJS案例     状态:可编辑再运行    进入横版
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<script src="/js/angular.js1.4.6/angular.min.js"></script> 
6
</head>
7
<body ng-app="myApp">
8
9
<!-- directive: w3xue-directive -->
10
11
<script>
12
var app = angular.module("myApp", []);
13
app.directive("w3xueDirective", function() {
14
    return {
15
        restrict : "M",
16
        replace : true,
17
        template : "<h1>自定义指令!</h1>"
18
    };
19
});
20
</script>
21
22
<p><strong>注意:</strong> 我们需要在该实例添加 <strong>replace</strong> 属性, 否则评论是不可见的。</p>
23
24
<p><strong>注意:</strong> 你必须设置 <b>restrict</b> 的值为 "M" 才能通过注释来调用指令。</p>

 运行结果 
 北美留学生论坛