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)的更多相关文章

  1. Directive Definition Object

    不知道为什么这个我并没有想翻译过来的欲望,或许我并没有都看熟透,不好误人子弟,原版奉上. Here's an example directive declared with a Directive D ...

  2. angularjs directive 实例 详解

    前面提到了angularjs的factory,service,provider,这个可以理解成php的model,这种model是不带html的,今天所说的directive,也可以理解成php的mo ...

  3. Angularjs directive全面解读(1.4.5)

    说到Angularjs directive即指令,可以这么说Angularjs的灵魂就是指令,学会Angularjs指令那么你的Angularjs的武功就修炼了一半了,当然这只是鄙人的一点点独到见解, ...

  4. 学习AngularJs:Directive指令用法

    跟我学AngularJs:Directive指令用法解读(上) http://blog.csdn.net/evankaka/article/details/51232895 跟我学AngularJs: ...

  5. 学习AngularJs:Directive指令用法(完整版)

    这篇文章主要学习AngularJs:Directive指令用法,内容很全面,感兴趣的小伙伴们可以参考一下   本教程使用AngularJs版本:1.5.3 AngularJs GitHub: http ...

  6. angularjs directive (自定义标签解析)

    angularjs directive (自定义标签解析) 定义tpl <!-- 注意要有根标签 --> <div class="list list-inset" ...

  7. angularJS directive中的controller和link function辨析

    在angularJS中,你有一系列的view,负责将数据渲染给用户:你有一些controller,负责管理$scope(view model)并且暴露相关behavior(通过$scope定义)给到v ...

  8. 步入angularjs directive(指令)--点击按钮加入loading状态

    今天我终于鼓起勇气写自己的博客了,激动与害怕并存,希望大家能多多批评指导,如果能够帮助大家,也希望大家点个赞!! 用angularjs 工作也有段时间了,总体感觉最有挑战性的还是指令,因为没有指令的a ...

  9. AngularJS Directive 隔离 Scope 数据交互

    什么是隔离 Scope AngularJS 的 directive 默认能共享父 scope 中定义的属性,例如在模版中直接使用父 scope 中的对象和属性.通常使用这种直接共享的方式可以实现一些简 ...

随机推荐

  1. BITED数学建模七日谈之五:怎样问数学模型问题

    下面进入数学建模经验谈第五天:怎样问数学模型问题 写这一篇的目的主要在于帮助大家能更快地发现问题和解决问题,让自己的模型思路有一个比较好的形成过程. 在我们学习数学模型.准备比赛的时候,经常会遇到各种 ...

  2. linux c 多线程编程

    linux 下 c 语言多线程: /* 06.3.6 Mhello1.c Hello,world -- Multile Thread */ #include<stdio.h> #inclu ...

  3. 安卓手机修改hosts攻略-摘自网络

    Android手机是和Google帐号紧密联系的,由于$^&情况,很多时候Google帐号无法登录,导致Android市场无法使用.在电脑上我们通过修改Hosts方法可以解决Google帐号的 ...

  4. Styling FX Buttons with CSS

    http://fxexperience.com/2011/12/styling-fx-buttons-with-css/ ——————————————————————————————————————— ...

  5. <一道题>abc+cba=1333,求满足条件的abc的值,隐含条件a!=0,c!=0

    这类东西,无非就是穷举法.见下面代码: #include <stdio.h> #include <stdlib.h> /* *abc + cba = 1333 * *a = ? ...

  6. Working with nil

    [Working with nil] It’s always a good idea to initialize scalar variables at the time you declare th ...

  7. AJAX小练习,防止以后忘记

    <div id="content"> <input id="btnShow" type="button" value=&q ...

  8. sql server中的decimal或者numeric的精度问题

    何谓精度:最多可以存储的十进制数字的总位数,包括小数点左边和右边的位数.该精度必须是从 1 到最大精度 38 之间的值.默认精度为 18. 小数位数:小数点右边可以存储的十进制数字的最大位数.小数位数 ...

  9. UI进阶 FMDB

    一.FMDB简介 1.FMDB简介 iOS中原生的SQLite API在进行数据存储的时候,需要使用C语言中的函数,操作比较繁琐.于是,就出现了一系列将SQLite API进行封装的库,例如FMDB. ...

  10. 图片转换成base64_encode的链接代码示例

    <?php $file = "example.jpg"; $type = getimagesize( $file ); //取得图片的大小,类型等 $file_content ...