ngtemplateoutlet dynamic code example
Example 1: ngtemplateoutlet
<ng-template #myTemplate> World! </ng-template>
Hello
<ng-container [ngTemplateOutlet]="myTemplate"></ng-container>
<>Copy
Example 2: ngtemplateoutlet
<ng-container
*ngTemplateOutlet="optionTemplate; context:{ $implicit: option, idx: i }"
></ng-container>
><Copy
Example 3: ngtemplateoutlet
<li *ngFor="let item of items; index as i">
<ng-container
[ngTemplateOutlet]="optionTemplate"
[ngTemplateOutletContext]="{ $implicit: option, idx: i }"
></ng-container>
</li>
<>Copy