3

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 ?

Zysce
  • 1,200
  • 1
  • 10
  • 35

1 Answers1

2

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567