Angular.js directive template using variable from parent/inherited scope

会有一股神秘感。 提交于 2019-12-25 01:59:46

问题


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?


回答1:


There is indeed no other way around. Although you should $compile this way to achieve somewhat satisfactory performance results. https://stackoverflow.com/a/22646392/301596



来源:https://stackoverflow.com/questions/22617574/angular-js-directive-template-using-variable-from-parent-inherited-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!