[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 中的对象和属性.通常使用这种直接共享的方式可以实现一些简 ...
随机推荐
- Ubuntu/CentOS使用BIND配置DNS服务器
------ubuntu server 12---------- 1.安装bind9 sudo apt-get -y install bind9 bind9utils 2.配置 /etc/bind/ ...
- Vi的基本使用方法
转载自http://linux.chinaunix.net/doc/office/2005-01-24/898.shtml vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何 ...
- 【boost】使用lambda表达式和generate_n生成顺序序列
程序中经常用到顺序序列(0,1,2,3,4,5,6.....),一直羡慕python有range这样的函数,而C++中通常只有用循环来处理这种初始化. 现在,结合boost库lambda(虽然差C++ ...
- Java基础 —— 概述
Java语言: JDK(Java Development Kit)开发工具包,提供Java的开发环境和运行环境 --> 适合于开发 JRE(Java Runtime Environment)Ja ...
- JDBC连接Oracle数据库的问题
场景:最近做一个java web项目,使用jdbc连接Oracle数据库,遇到了两个问题. 问题1:jdbc连接不上Ubuntu Oracle服务器? 后来发现这个问题的原因是由于连接字符串写错了,修 ...
- 桶排序-C-结构体排序
struct TS { int index; ]; }; ] = {{,,,,,"s8"}}; ]; int i; int length = sizeof(a) / sizeof ...
- iOS 后台退出app时不执行applicationWillTerminate的临时解决方法
- (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release s ...
- Cocos2d-JS v3.0 alpha 导入 cocostudio的ui配置
1.在新项目的根文件夹下打开project.json文件,修改: "modules" : ["cocos2d", "extensions", ...
- ProxyFactory的一个问题
今天写了一段很简单的代码,但一直都有问题.代码如下. 接口定义 using System; using System.Collections.Generic; using System.Linq; u ...
- poj 1273 Drainage Ditches(最大流)
http://poj.org/problem?id=1273 Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Subm ...