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,150
  • 1
  • 10
  • 33

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
  • 558,509
  • 191
  • 1,911
  • 1,506