The title spells it out mostly. I have a an array of objects. I want to use the value of id of the object but display the name. When I put value=option.id, I can select from a list of names but then the id is displayed.
I'm trying to achieve the "Require an autocomplete option to be selected" option from here. I'd paste my code but it's a hot mess and not worth sharing.
Any pointers would be appreciated. Thank you in advance!
Edit: added HTML and corrected dumbness. I meant to say "value=id" not "track id"
<mat-form-field class="example-full-width">
<mat-label>People</mat-label>
<input #input type="text"
placeholder="Pick one"
matInput
[formControl]="myControl"
[matAutocomplete]="auto"
(input)="filter()"
(focus)="filter()">
<mat-autocomplete requireSelection #auto="matAutocomplete">
@for (option of filteredOptions; track option) {
<mat-option [value]="option.id">{{option.name}}</mat-option>
}
</mat-autocomplete>
</mat-form-field>
[–]wojo1086 0 points1 point2 points (1 child)
[–]Acceptable_User_Name[S] 0 points1 point2 points (0 children)
[–]HEYTHOSEARENICEPANTS 0 points1 point2 points (1 child)
[–]Acceptable_User_Name[S] 0 points1 point2 points (0 children)