【问题标题】:inject HTML in a dynamic ng-include template在动态 ng-include 模板中注入 HTML
【发布时间】:2014-01-22 22:00:06
【问题描述】:

我有以下指令

...
template: <div ng-include={{model.template}} \>
...

模板是动态的。我想通过指令链接或编译阶段在该模板中注入额外的 HTML。我该怎么做?

【问题讨论】:

  • 模板是动态的是什么意思?请举个例子
  • 意思改变了。现在我想起来了,这与我的问题无关。我只想在该模板中插入额外的标记而不修改该模板本身。

标签: angularjs


【解决方案1】:

使用函数将模板作为字符串返回:

函数解析模板(tElement,tAttrs){ } angular.module('MyApp').directive('maybeLink', function() { 返回 { //... 模板:resolveTemplate, //... }; });

更多详情请参阅此答案:https://stackoverflow.com/a/21105774/149060

【讨论】:

    猜你喜欢
    • 2017-01-12
    • 1970-01-01
    • 1970-01-01
    • 2017-07-22
    • 1970-01-01
    • 2018-07-18
    • 2017-02-07
    • 2014-01-15
    • 1970-01-01
    相关资源
    最近更新 更多