【问题标题】:Dynamic directives from within a resource property资源属性中的动态指令
【发布时间】:2013-04-04 20:06:38
【问题描述】:

我有一个资源中继器,该资源包含一个内部带有角度指令的属性,并与文本混合。我想要完成的是根据对象的属性动态显示表单输入。

<ul>
  <li ng-repeat="action in actions">
    {{action.form_layout}}
  </li>
</ul>

在这种情况下,action.form_layout 可能包含一些带有指令的文本,这些文本也需要编译。

Open the <door></door> with this <key></key>
// <door> and <key> are directives that would return different inputs
// so this should be compiled to Open the <input type="text" name="door"></input> with this <input type="text" name="key"></input>

我怎样才能做到这一点?现在,属性值正在模板中以纯文本形式打印。

谢谢

【问题讨论】:

  • 为演示提供示例数据以及您到目前为止所尝试的内容

标签: javascript angularjs angularjs-directive


【解决方案1】:

请看看这个小提琴。 http://jsfiddle.net/dH5Ln/ 这里doorkey 被分隔为单独的指令。在compile函数的帮助下,我们正在解析模板并显示编译后的模板。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-03
    • 2020-10-08
    • 2015-10-05
    • 1970-01-01
    • 1970-01-01
    • 2016-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多