In my angular 5 application I have some matAutocomplete, but I want to force the selection of oone of suggestions, so I am following this approach: stackblitz but for some reas
I found this helpful:
private subscribeToClosingActions(): void {
if (this.subscription && !this.subscription.closed) {
this.subscription.unsubscribe();
}
this.subscription = this.autoCompleteTrigger.panelClosingActions
.subscribe((e) => {
if (!e || !e.source) {
const selected = this.matAutocomplete.options
.map(option => option.value)
.find(option => option === this.formControl.value);
if (selected == null) {
this.formControl.setValue(null);
}
}
},
err => this.subscribeToClosingActions(),
() => this.subscribeToClosingActions());
}