[AngularJS] Directive Definition Objects (DDO)
angularjs directive Objects definition
2023-09-14 08:59:21 时间
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清除浏览器缓存
- AngularJS进阶(二)AngularJS路由问题解决
- angularjs技术
- 前端框架:第一章:AngularJS
- 技术汇总:第五章:使用angularjs做首页三级分类
- [angularjs] angularjs系列笔记(四)过滤器详解编程语言
- AngularJS的Scope(作用域)学习详解编程语言
- AngularJS 依赖注入详解编程语言
- TypeScript 2.0 与 AngularJS 2.0 的新动态
- AngularJS中使用HTML5摄像头拍照
- AngularJS入门知识之MVW类框架的编程思想探讨
- Angularjs基础知识及示例汇总
- AngularJS语法详解(续)