我使用mat-select
与mat-option
,但我想重置mat-option
选择当我点击一个按钮。因此,我希望屏幕上显示没有值的选项,而不是将其值设置为null
。
的例子:
<div ngIf="listAccounts">
<mat-select [(value)]="accountSelected">
<mat-option>Select an option... </mat-option>
<mat-option [value]="account" *ngFor="let account of listOfAccounts" (click)="yourFunction(account)">
Account {{account.accountNumber}} Agency {{account.agencyNumber}} Digit{{account.digitNumber}}
</mat-option>
</mat-select>
<div>
<button (click)="listedAccounts = !listedAccounts"> Button </button>
每次我点击按钮,我想要mat-option
转到"Select an option..."
或一个空选项。
将accountSelected
设置为空值,并更改mat-option
<mat-option value=''>Select an option... </mat-option>