3

In my app.component.ts I have an array with the component tags.

compData = ['app-component-one', 'app-component-two', 'app-component-three'];

Then in my app.component.html I have this:

<div *ngFor="let comps of compData">

    // I tried this: {{comps}} but that will not render the components

</div>

How can I do this so I can render each component?

Erik Philips
  • 51,408
  • 11
  • 123
  • 146

1 Answers1

4

You cannot render components from array, instead you need to look at dynamic component generator

https://angular.io/guide/dynamic-component-loader

Sajeetharan
  • 203,447
  • 57
  • 330
  • 376