惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Project Zero
Project Zero
D
DataBreaches.Net
博客园_首页
罗磊的独立博客
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Forbes - Security
Forbes - Security
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
雷峰网
雷峰网
Jina AI
Jina AI
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 三生石上(FineUI控件)
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
SegmentFault 最新的问题
V
Visual Studio Blog
Webroot Blog
Webroot Blog
GbyAI
GbyAI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
IT之家
IT之家
C
Cyber Attacks, Cyber Crime and Cyber Security
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
T
Troy Hunt's Blog
博客园 - 叶小钗
N
News and Events Feed by Topic
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
C
Check Point Blog
T
Threatpost
SecWiki News
SecWiki News
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
P
Privacy International News Feed
J
Java Code Geeks
L
LINUX DO - 最新话题
PCI Perspectives
PCI Perspectives
T
Tailwind CSS Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cisco Blogs
S
Schneier on Security

博客园 - 开发手游啦啦啦

用TypeScript开发爬虫程序 ABP导航源码分析 ABP的语言切换 AngularJs自定义指令详解(10) - 执行次序 AngularJs自定义指令详解(9) - terminal AngularJs自定义指令详解(8) - priority AngularJs自定义指令详解(7) - multiElement AngularJs自定义指令详解(6) - controller、require AngularJs自定义指令详解(5) - link AngularJs自定义指令详解(4) - transclude AngularJs自定义指令详解(3) - scope AngularJs自定义指令详解(2) - template ABP的Zero Sample ABP的工作单元 ABP的数据过滤器(Data Filters) ABP的事件总线和领域事件(EventBus & Domain Events) 初入Cocos2d-x 2.2 quick-cocos2d-x之testlua之VisibleRect.lua quick-cocos2d-x之testlua之mainMenu.lua
AngularJs自定义指令详解(1) - restrict
开发手游啦啦啦 · 2015-07-03 · via 博客园 - 开发手游啦啦啦

下面所有例子都使用angular-1.3.16。下载地址:http://cdn.bootcss.com/angular.js/1.3.16/angular.min.js

既然AngularJs快要发布2.0,所以现在也没必要追求最新版本。而且,2.0变动实在太大,所以当前学习AngularJs不需要过度深入。

AngularJs自定义指令时,要求返回一个指令定义对象(Directive Definition Object),该对象可以声明若干属性和方法。下面例子的restrict、template就是其中之一。

restrict是一个可选的参数,若不声明,则取默认值EA。

可选值包括:E(元素)A(属性)C(类名)

混合使用:如:EA,表示既可以作为E也可以作用A。

例子:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script src="../lib/angular-1.3.16/angular.min.js"></script>
    <script src=""></script>
    <title></title>
    <script language="JavaScript">
        angular.module('app',[])
                .directive('myDirective',function(){
                    return{
                        restrict:'EAC',
                        template:'Hello World!'

                    };
                });
    </script>
</head>
<body ng-app="app">
<my-directive></my-directive>
<div my-directive></div>
<div class="my-directive"></div>
</body>
</html>

在Google Chrome查看:

点击右键-审查元素(或快捷键ctl+shift+i),可以看到:

注意‘Hello World!’字符串的插入位置。