文章内容
2020/5/26 15:11:14,作 者: 黄兵
mat-autocomplete select event事件处理
最近在使用Angular Material,mat-autocomplete select event事件具体写发:
<mat-autocomplete #auto="matAutocomplete" (optionSelected)='getPhoneNumber($event.option.value)'>
<mat-option *ngFor="let option of filteredOptions | async" [value]="option.id">
{{option.name}}
</mat-option>
</mat-autocomplete>
getPhoneNumber($event.option.value)
具体处理函数:
getPhoneNumber(phoneNumberId: number) { if (phoneNumberId === null) { return false; } // 跳转到号码详情页面 this._router.navigate(['phoneNumber/details/', phoneNumberId]).then(r => r); }
同时这里有一个在线示例:@vivekdoshi2 / angular-mat-autocomp-dependent
具体API的介绍在这里,可以看看:API reference for Angular Material autocomplete
评论列表