Search code examples
angularangular-materialangular-material-6mat-autocomplete

how to open mat-autocomplete panel on the 'optionSelected' event of another mat-autocomplete?


how to open mat-autocomplete panel on the (option-Selected) event of another mat-autocomplete

please refer the example here https://stackblitz.com/edit/angular-material-autocomplete-mqnxp5


Solution

  • The problem with opening the other list from the selected event is that the event sequence for the first list is still in progress. Waiting until after is necessary, which is done using setTimeout():

    onStateChanged(){
      setTimeout(() => {
        this.cityInput.openPanel();
      });
    }