在模板中我想做一些类似的事情:
<my-{{data.type}}></my-{{data.type}}>
但它不会取代 {{data.type}}
标记。
有解决方案或解决方法吗?
最佳答案
你不能这样做,但你可以使用 ng-switch ,例如,
<div ng-switch="data.type">
<div ng-switch-when="test1">
<my-test1></my-test1>
</div>
<div ng-switch-when="test2">
<my-test2></my-test2>
</div>
</div>
关于javascript - Angular js : build directive tag in template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25099241/