【发布时间】:2014-08-28 04:50:33
【问题描述】:
在编写 Angular 指令时,可以使用以下任何函数来操作声明该指令的元素的 DOM 行为、内容和外观:
- 编译
- 控制器
- 预链接
- 链接后
对于应该使用哪个功能似乎有些混乱。这个问题涵盖:
指令基础
- How to declare the various functions?
- What is the difference between a source template and an instance template?
- In which order the directive functions are executed?
- What else happens between these function calls?
功能性质,注意事项
相关问题:
- Directive: link vs compile vs controller。
- Difference between the 'controller', 'link' and 'compile' functions when defining an angular.js directive。
- What is the difference between compile and link function in angularjs。
- Difference between the pre-compile and post-compile element in AngularJS directives?。
- Angular JS Directive - Template, compile or link?。
- post link vs pre link in Angular js directives。
【问题讨论】:
-
什么什么?
-
@Ian See:Operator overloading。本质上,这是为社区 wiki 设计的。太多相关问题的答案都是片面的,没有提供完整的情况。
-
这是很棒的内容,但我们要求这里的所有内容都保持在问答格式中。也许您想将其分解为多个离散的问题,然后从标签 wiki 链接到它们?
-
尽管这篇文章是题外话并且是博客形式的,但它在提供对 Angular 指令的深入解释方面最有用。请不要删除这篇文章,管理员!
-
老实说,我什至不关心原始文档。 stackoverflow 帖子或博客通常能让我在几秒钟内完成,而我需要 15 到 30 分钟才能理解原始文档。
标签: angularjs angularjs-directive