b. *_*eck 8 angularjs angularjs-directive
我有一个Angular指令,用于创建手风琴<ol>和<li>元素,每个<li>内容都包含在一个被转换的模板中.我需要触发一个方法来检查这些<li>元素中是否有任何错误,然后打开那个手风琴,但是在转换元素之后我找不到触发方法的方法.
是否有正确计时的钩子或指令配置?
我想您可以访问postLink指令定义对象中定义的函数中的内容。查看官方文档。
指令定义对象使您能够定义:
compile: function compile(tElement, tAttrs, transclude) {
return {
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
post: function postLink(scope, iElement, iAttrs, controller) { ... }
}
// or
// return function postLink( ... ) { ... }
},
Run Code Online (Sandbox Code Playgroud)
在那里您可以注入和访问 iElement 及其内容。这是在模板编译之后发生的,因此<li>元素应该已经就位。
| 归档时间: |
|
| 查看次数: |
784 次 |
| 最近记录: |