I am having a hard time trying to get *ngFor to work in a DataList with input.
This works...
<input
type="text" class="form-control" list="tktnum"
placeholder="Ticket Number..." [(ngModel)]="dbParams.tktNum"
>
<datalist id="tktnum">
<option>{{tktVals[0].TicketNo}}</option>
<option>{{tktVals[1].TicketNo}}</option>
<option>{{tktVals[2].TicketNo}}</option>
</datalist>
But this doesn't...
<input
type="text" class="form-control" list="tktnum"
placeholder="Ticket Number..." [(ngModel)]="dbParams.tktNum"
>
<datalist id="tktnum">
<option *ngFor="let a of tktVals">{{ a.TicketNo }}</option>
</datalist>
The dropdown box remains empty when I use the second block of code.
What I tried
I have tried to create a new angular app, with only this piece of code and that has worked, but when I try to include it in the actual app, *ngFor doesn't work. I am using *ngFor in an HTML table in the actual app, which is working just fine. The problem seems to only be with the DataList and that too in the app that I am working on. I am using VS Code and updated it to the latest version, recompiled the app from the beginning. I am working on a Windows 10 machine.
Here's the typescript code - with unrelated items removed
export class TicketReportComponent implements OnInit {
tktVals: Array<{TicketNo: string}>;
ngOnInit(): void {
this.tktVals = [{"TicketNo": "1"}, {"TicketNo": "2"}];
}
}