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
  • 53,428
  • 11
  • 128
  • 150

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
  • 216,225
  • 63
  • 350
  • 396