In my html I have this piece of code
Html...
<input type="text" list="select" [(ngModel)]="appSelect" (change)="picked($event.target.value)" />
<datalist id="select">
<option selected="" value="">Select...</option>
<option *ngFor="let i of app; let x = index" [value]="i.info" >{{i.name}}</option>
</datalist>
Component...
appSelect: any;
picked(value: any) {
console.log (value);
}
above prints what I want but the dropdown shows 2 values. With i.info on the left and i.name on the right in the dropdown column.
Dropdown: [i.info i.name]
I wanted to show only the i.name in the dropdown column
Dropdown: [i.name]
Now...I have tried a different approach.
Html....
<input type="text" list="select" [(ngModel)]="selectedVal" (ngModelChange)="picked($event)" />
<datalist id="select">
<option selected="" value="">Select...</option>
<option *ngFor="let i of app; let x = index" [ngValue]="i" >{{i.name}}</option>
</datalist>
@Input() selectedVal: string;
picked(value: any) {
console.log (value);
}
Above shows correct value in the dropdown
Dropdown: [i.name]
But the issue is that the value passed to picked is [i.name]
and not [i.info]
So how do I get the info passed in while show the name only in the dropdown display?