I want to render components in a list, but I cannot do this statically. Based on user import I can determine which components I have to show. The problem also is that depending on input inside those components the list can change too
Right now I have everything hardcoded in HTML with a lot of *ngIfs. This worked well but as the complexity of my app increased this approach seems to becoming hard to maintain.
Anyway, my solution is to render the components dynamically, so I only need to create a list of components I would like to render.
Here is a nice article which describes how to dynamically add one component. You create a template
<template #alertContainer></template>
to which you add the dynamic component
const factory: ComponentFactory = this.resolver.resolveComponentFactory(AlertComponent);
this.componentRef: ComponentRef = this.container.createComponent(factory);
However, in my case I have a list
<ol>
<li *ngFor="let component of components">
<template ........</template>
</li>
</ol>
So how can I create a list in this case (I also need to bind to @Inputs and @outputs)?