Levente Gal
Levente Gal

Reputation: 114

angular js: build directive tag in template

In a template I would like to do something like:

<my-{{data.type}}></my-{{data.type}}>

but it doesn't replace the {{data.type}} markup.

Is there a solution or a workaround for this?

Upvotes: 1

Views: 50

Answers (1)

az7ar
az7ar

Reputation: 5237

You can't do that but you can use ng-switch like,

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

Upvotes: 1

Related Questions