javascript - 是否可以在指令链接函数中获取模板内容?

标签 javascript angularjs angularjs-directive

我想重复使用指令模板。我怎样才能在链接函数中访问它?

我期望类似的东西

this.template

最佳答案

您必须使用模板缓存服务。

$templateCache.get('path/to/template/my.html')

http://docs.angularjs.org/api/ng/service/$templateCache

关于javascript - 是否可以在指令链接函数中获取模板内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22092934/

相关文章:

javascript - 从指令调用函数到 Controller

javascript - 如何在angular4项目中导入angular2-cookie

javascript - 将 html 文件放入 iframe 或 div 中并单击它

html - 如何以编程方式创建 DragEvent?

angularjs - Angular.js 与 React.js 与 php mvc (Laravel)

javascript - 使用 $compile 以编程方式添加指令并从范围传递数据,

javascript - 要求未找到 Angular Directive(指令) Controller

javascript - 我可以将多个原型(prototype)方法绑定(bind)到对象实例吗?

javascript - 如何在 react 中使用 highcharts 绘制圆环图迷你图?

javascript - 封装Web服务数据的Angular服务