I have took autocomplete example from Material official web site and changed getting options from variable of component class to function, options display but I can't select anything, clicking on drop-down doesn't select a value.
Here is sample project on StackBlitz.
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of options()" [value]="option">
{{option.value}}
</mat-option>
</mat-autocomplete>
export class AutocompleteSimpleExample {
myControl = new FormControl();
options(): KeyValue[] {
return [{ key: "1", value: "One" }];
}
}
interface KeyValue {
key: string;
value: string;
}