Iwo*_*woo 3 select focus angular
在 .html 文件中我有选择器:
<mat-form-field>
<mat-select #selector(selectionChange)="onSelectionChange($event.value)">
<mat-option *ngFor="let test of tests" [value]="test">
</mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
在 .ts 文件中我有:
@ViewChild('selector', { static: false }) selector: MatSelect
onSelectionChange(value: any) {
this.selector.focused = false;
}
Run Code Online (Sandbox Code Playgroud)
它不起作用,因为 focus 是只读参数,但如何以其他方式实现此效果?
MatSelect 公开close方法。
尝试这个:
onSelectionChange(value: any) {
this.selector.close();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4490 次 |
| 最近记录: |