Reputation: 1240
I would like to dynamically build selector or call component in the template with a property. Like in this plunker.
Example :
<!-- What I want to do -->
<frame-{{type}}></frame-{{type}}>
<!-- Or -->
<frame [type]="{{type}}"></frame>
Is there a workaround for this or is it not possible with angular2 ?
Upvotes: 3
Views: 1849
Reputation: 657731
That's at least currently not supported. Components and directives are only applied to static HTML.
You can use DynamicComponentLoader ViewContainerRef.createComponent to imperatively add/remove comonents.
Upvotes: 2