1

I'm currently doing something like

<div *ngFor="let directive in listOfDirectives">
    <directive-one *ngIf="directive == 'directive-one'"></directive-one>
    <directive-two *ngIf="directive == 'directive-two'"></directive-two>
    ...
</div>

What I'd like to do is this however it doesn't work

<{{directive}} *ngFor="let directive = listofDirectives"></{{directive}}>

So is there a way to do this? For styling purposes i really need the to not be wrapped with a div

matthewdaniel
  • 1,842
  • 4
  • 21
  • 35

1 Answers1

2

Something like

<{{directive}} *ngFor="let directive = listofDirectives"></{{directive}}>

is not supported.

Only HTML that is statically added to a template is matched against selectors of components and directives.

You can add dynamic components using ViewContainerRef.createComponent like explained for example in Angular 2 dynamic tabs with user-click chosen components

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