【发布时间】:2016-01-27 01:23:23
【问题描述】:
在 Angular 指令的编译函数中有一个 pre 和 post。这个pre和post真的和link功能一样吗?
例如在下面的代码中,链接函数是否与它下面的编译函数的 pre 和 post 相同(如果你愿意,可以使用快捷方式)?
链接
....
link: {
pre: function(scope, elem, attr) {
//stuff
},
post: function(scope, elem, attr) {
//stuff
}
}
....
编译...
....
compile: function(tElem, tAttrs){
return {
pre: function(scope, iElem, iAttrs){
//stuff
},
post: function(scope, iElem, iAttrs){
//stuff
}
}
}
.....
【问题讨论】:
标签: javascript angularjs angularjs-directive angularjs-scope angularjs-ng-repeat