I am creating a grid component with a custom cell configuration. Currently, since I can set up a custom cell element in a cell configuration, I store a whole bunch of templates, for example:
<template let-row="row" #nameCell>
<name-cell [row]="row"></name-cell>
</template>
Getting the template and saving it in the grid configuration:
@ViewChild('nameCell') nameCell: TemplateRef<any>;
...
column.customCell = nameCell
And how to use this template in the grid cell:
<template
*ngIf="column.customCell"
[ngTemplateOutlet]="column.customCell"
[ngOutletContext]="{ row: row}">
</template>
It works, but it looks dirty and dirty. Is there a way to dynamically load a TemplateRef from an external file?
source
share