资源属性中的动态指令

时间:2013-04-04 20:06:38

标签: javascript angularjs angularjs-directive

我有一个资源的转发器,其中包含一个带有angular指令的属性,与文本混合。我想要完成的是根据对象的属性动态显示表单输入。

<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>

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

由于

1 个答案:

答案 0 :(得分:1)

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

相关问题