[AngularJS] Directive Definition Objects (DDO)
This function that we just set up is what's called a link function, and it's actually a very small part of a larger API. If I cut this and instead I return an object and it has a property of link with that function, you'll see that this will behave the exact same way. Now this object that we are returning here is called the directive definition object, or DDO if you want an acronym for it. There's plenty of things on here for you to configure.
var egghead = angular.module("egghead", []);
egghead.controller("AppCtrl", function () {
var app = this;
app.message = "Hello";
})
egghead.directive("myFirstDirective", function () {
return function (scope, element, attrs) {
element.text(scope.app.message + " " + attrs.message);
}
})
TO:
var egghead = angular.module("egghead", []);
egghead.controller("AppCtrl", function () {
var app = this;
app.message = "Hello";
})
egghead.directive("myFirstDirective", function () {
return {
link: function (scope, element, attrs) {
element.text(scope.app.message + " " + attrs.message);
}
}
})
There are many other definitions can put here.
Read More:
https://docs.angularjs.org/guide/directive
[AngularJS] Directive Definition Objects (DDO)的更多相关文章
- Directive Definition Object
不知道为什么这个我并没有想翻译过来的欲望,或许我并没有都看熟透,不好误人子弟,原版奉上. Here's an example directive declared with a Directive D ...
- angularjs directive 实例 详解
前面提到了angularjs的factory,service,provider,这个可以理解成php的model,这种model是不带html的,今天所说的directive,也可以理解成php的mo ...
- Angularjs directive全面解读(1.4.5)
说到Angularjs directive即指令,可以这么说Angularjs的灵魂就是指令,学会Angularjs指令那么你的Angularjs的武功就修炼了一半了,当然这只是鄙人的一点点独到见解, ...
- 学习AngularJs:Directive指令用法
跟我学AngularJs:Directive指令用法解读(上) http://blog.csdn.net/evankaka/article/details/51232895 跟我学AngularJs: ...
- 学习AngularJs:Directive指令用法(完整版)
这篇文章主要学习AngularJs:Directive指令用法,内容很全面,感兴趣的小伙伴们可以参考一下 本教程使用AngularJs版本:1.5.3 AngularJs GitHub: http ...
- angularjs directive (自定义标签解析)
angularjs directive (自定义标签解析) 定义tpl <!-- 注意要有根标签 --> <div class="list list-inset" ...
- angularJS directive中的controller和link function辨析
在angularJS中,你有一系列的view,负责将数据渲染给用户:你有一些controller,负责管理$scope(view model)并且暴露相关behavior(通过$scope定义)给到v ...
- 步入angularjs directive(指令)--点击按钮加入loading状态
今天我终于鼓起勇气写自己的博客了,激动与害怕并存,希望大家能多多批评指导,如果能够帮助大家,也希望大家点个赞!! 用angularjs 工作也有段时间了,总体感觉最有挑战性的还是指令,因为没有指令的a ...
- AngularJS Directive 隔离 Scope 数据交互
什么是隔离 Scope AngularJS 的 directive 默认能共享父 scope 中定义的属性,例如在模版中直接使用父 scope 中的对象和属性.通常使用这种直接共享的方式可以实现一些简 ...
随机推荐
- 单独删除std::vector <std::vector<string> > 的所有元素
下面为测试代码: 1.创建 std::vector< std::vector<string> > vc2; 2.初始化 std::vector<string> vc ...
- The remote SSH server rejected X11 forwarding request
两台相同的虚拟机,一台没有错误,一个经常出现警告,内容如下所示: The remote SSH server rejected X11 forwarding request 找了很多方法,最后发现是安 ...
- 在 Asp.NET MVC 中使用 SignalR 实现推送功能
一,简介Signal 是微软支持的一个运行在 Dot NET 平台上的 html websocket 框架.它出现的主要目的是实现服务器主动推送(Push)消息到客户端页面,这样客户端就不必重新发送请 ...
- Office2013版的破解之路
追着潮流,我还是更新了我的所有软件,2013版早就下载了,因为一直破解的问题没有装,这次终于找到必成功的办法. 1.准备工作: 下载office2013的官方版即可,官方版里不包含project和vi ...
- Linux中的.emacs文件
刚开始的时候在Windows下使用emacs,那个时候配置 .emacs文件直接去C盘里\Users\(username)\AppData\Roaming 路径下查找就可以了(最开始的时候可以打开em ...
- AI钻石天鹅风格
第1步:描绘轮廓 你需要对你的设计有个总体的概念.利用照片和钢笔工具(P)描出轮廓.把填充颜色设为无,描边颜色设为黑色,1pt 粗细.这将作为你完成剩下设计的指导.编组 (Ctrl+G)你的线条并在图 ...
- 图解WPF程序打包全过程
首先打开已经完成的工程,如图: 下面开始制作安装程序包. 第一步:[文件]——[新建]——[项目]——安装项目. 名称——可以自己根据要求修改. 位置——是指你要制作的安装文件存放在什么目录内,可以根 ...
- Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
mvn war:war命令出错: 原因: maven的web项目默认的webroot是在src\main\webapp.如果在此目录下找不到web.xml就抛出以上的异常. 解决方案: 在pom.xm ...
- C_functions
1.C常用函数分为如下几大类!! 1,字符测试函数. 2,字符串操作 3,内存管理函数 4,日期与时间函数 5,数学函数 6,文件操作函数 7,进程管理函数 8,文件权限控制 9,信号处理 10,接口 ...
- delphi 判断调试状态
DebugHook 该变量在调试状态下值为1,运行模式为0,例如,我们可以使用如下的代码来简单控制: if DebugHook=0 then