I am using mat-auto complete component from material.angular.io. The default behavior is user can input any value as well as it gives options to choose from. Also you can add yo
You can do something like this
Markup:
{{ option.name }}
Component:
selectedOption;
changeMyControl(): void {
if (isUndefined(this.selectedOption) {
// also check selected item and entered text are not same
this.myForm.get('myControl').setErrors({'incorrect': true});
}
}
onSelectedOption(isSelected: boolean, id: number): void {
if (isSelected) {
setTimeout(() => {
const option = this.options.filter(bt => bt.id === id);
if (option.length > 0) {
this.selectedOption= option[0];
// patch formcontrol value here
}
}, 200);
}
}