问题描述
我想这取决于从它的父作用域一些变量来选择指令templateUrl。我不能使用templateUrl功能,因为它不具有一个范围爱好。我可以在$编译从$ templateCache模板(请注意,它已经存在,我不会加载它)从联函数内部,但恐怕也要去会对性能产生负面影响(我们说这是一个表格单元格指示..而且有相当多的细胞)。
I want to chose directives templateUrl depending on some variable from its parent scope. I can't use templateUrl function, since it doesn't have a scope yet. I can $compile the template from $templateCache(note that it's already there, I'm not loading it) from inside the linking function, but I am afraid it's gonna have a negative impact on performance(let say this is a table cell directive.. and there's quite a few cells).
我是否有任何其他更好的选择?
Do I have any other, better option?
推荐答案
有确实周围也没有其他办法。虽然你应该 $编译
这种方式实现尚令人满意的性能结果。
There is indeed no other way around. Although you should $compile
this way to achieve somewhat satisfactory performance results.http://stackoverflow.com/a/22646392/301596
这篇关于使用来自父/继承范围的变量Angular.js指令模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!