The Material Autocomplete component has its own
optionSelected
event output:
Template:
<mat-autocomplete (optionSelected)="onSelectionChanged($event)">
<mat-option *ngFor="let item of myItems" [value]="item">
{{ item }}
</mat-option>
</mat-autocomplete>
Controller:
import { MatAutocompleteSelectedEvent } from '@angular/material';
// ...
onSelectionChanged(event: MatAutocompleteSelectedEvent) {
console.log(event.option.value);
}
Không có nhận xét nào:
Đăng nhận xét