如何在单击时将垫子选择重置为初始状态?
我正在使用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
转到“选择一个选项...”
或一个空选项。
I'm using mat-select
with mat-option
but I want to reset the mat-option
selected when I click on a button. So instead of just set its value to null
, I want the option without value to be displayed on the screen.
Example:
<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>
Everytime I click on the button I want to mat-option
go to "Select an option..."
or an empty option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将空值设置为
accountsclected
,然后在mat-option
中更改just set empty value to
accountSelected
and change inmat-option
将初始值添加到“重置”按钮上单击的单击使用多选择下拉
html
typescript
Add the initialvalue to empty on Reset button click with multi select dropdowns
HTML
Typescript