I am looking for a way to figure out when an mat-option
inside the mat-autocomplete
was either clicked or was selected using the enter key.
The click
event binding works as expected but the keyup.enter
or even just the keyup
event doesn't work.
Is this a bug in the library or I am doing something wrong?
<mat-option (click)="onEnter()" (keyup.enter)="onEnter()" *ngFor="let state of filteredStates | async" [value]="state.name">
Here's a live example - https://angular-3okq5u.stackblitz.io
Update: Please mention if there's a better way to handle the selection of an option at the <mat-option>
element level.