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. windows10UWP开发真机调试时遇到DEP6100和DEP6200解决办法

    windows10UWP开发真机调试时遇到DEP6100和DEP6200(其实未连接上设备都会报这两个错误,无论真机还是虚拟机)…… 此方法适合真机调试时遇到: 弹出提示框要求输入配对码,无论如何输入 ...

  2. linux设置主机名

    第一种方式: hostname 在hostname 命名后面直接加想要更改的主机名,修改成功,键入hostname可以查看修改后的主机名,此种方式会立即生效,但是重启后还原.不会永久修改 第二种方式: ...

  3. Hibernate中openSession() 与 getCurrentSession()的区别

    1 getCurrentSession创建的session会和绑定到当前线程,而openSession每次创建新的session. 2 getCurrentSession创建的线程会在事务回滚或事物提 ...

  4. android学习笔记---发送状态栏通知

    发送消息的代码如下: //获取通知管理器 NotificationManager mNotificationManager = (NotificationManager) getSystemServi ...

  5. phonegap 新窗口 inappbrowser插件

    在Phonegap 开发过程中,需要调用外部网页,又要跳出白名单安全限制,可以使用 inappbrowser插件. http://plugins.cordova.io/#/package/org.ap ...

  6. SharePoint咨询师之路:备份和恢复系列三 - 备份web和服务应用程序

    本系列包括: 备份服务器场和配置 备份web和服务应用程序 备份内容数据库 备份网站集 备份自定义项 备份web应用程序和服务应用程序一样有三种方式:SharePoint管理中心网站.Windows  ...

  7. Home vs2013

        Microsoft Visual Studio Ultimate 2013 版本 12.0.30110.00 Update 1 Microsoft .NET Framework 版本 4.5. ...

  8. 实体框架 (EF) 入门 => 五、连接和模型

    public class BloggingContext : DbContext  {  public BloggingContext()          : base("name=Blo ...

  9. 【下有对策】verycd没有的资源有很多方法下载

    由于国内专门从事假冒电驴官方欺骗中国人的verycd公司出品的冒牌官方电驴"阉割驴"目前已经阉割掉了搜索功能,请电驴爱好者们尽快更换正宗版电驴软件: 电骡--emule官方网站:h ...

  10. GWT工程架构分析与理解

    上一篇文章中介绍了GWT技术的一些理论性的东西,涉及到GWT得一些技术原理及实现.接下来笔者将通过创建一个GWT工程去理解分析GWT工程架构.     GWT工程架构解析 笔者使用的是Eclipse插 ...