0
votes

Is there a solution to prevent mat-autocomplete from updating the input on optionSelect ?

the goal is to obtain a list of suggestions after the user types some input and when the user selects one element from the dropdown hide the dropdown, leave the input with the same value and execute some arbitrary action with the selected element data

1

1 Answers

0
votes

my solution was to patch the MatAutocompleteTrigger

   @ViewChild(MatAutocompleteTrigger) auto!: MatAutocompleteTrigger;

   ngAfterViewInit() {
    const auto = this.auto;
    auto._setValueAndClose = (event: any)=>{
      auto.closePanel()
      console.log(event.source._mostRecentViewValue)
    }
  }