I'm working with an object that looks like this
let obj = [{
templateId: 1,
name: "Template 1"
}, {
templateId: 2,
name: "Template 1"
}, {
templateId: 3,
name: "Template 1"
}];
Within my HTML Template, I'm attempting to pass data to different templates based on the templateId as shown below
<div *ngFor="let tmpl of obj">
<div *ngIf="tmpl.templateId == 1; else templateTwo; context: tmpl">
{{ tmpl.name }}
</div>
</div>
<ng-template #templateTwo let-data="data">
<div *ngIf="data.templateId == 2; else templateThree; context: data">
{{ data.name }}
</div>
</ng-template>
<ng-template #templateThree let-data="data">
<div *ngIf="data.templateId == 3">
{{ data.name }}
</div>
</ng-template>
Even though I have structured my HTML template to pass data based on the templateId, I am facing errors in the code. Can you please guide me on what mistake I might be making here?
I would appreciate it if you could provide me with the correct approach.