I'm working on a data grid module. In the grid cells I need to display several types of data. So every cell is a component. Currently I'm using a ComponentFactoryResolver to generate the cells. Something like this:
<div *ngFor="let row of grid.data">
<app-dynamic-content [context]="row" [type]="type"></app-dynamic-content>
</div>
But there is an another solution without ComponentFactoryResolver, only using *ngIf to decide which component to display in the cell:
<div *ngFor="let row of grid.data">
<app-row-something *ngIf="type === 'rowType1'" data="row"></app-row-something>
<app-row-something2 *ngIf="type === 'rowType2'" data="row"></app-row-something2>
<app-row-something3 *ngIf="type === 'rowType3'" data="row"></app-row-something3>
<app-row-something4 *ngIf="type === 'rowType4'" data="row"></app-row-something4>
<app-row-something5 *ngIf="type === 'rowType5'" data="row"></app-row-something5>
...
</div>
Which one has the better performance and why?