如何使用Angular8/Material在mat Select中添加全选触发器
我创建了以下代码:如何使用Angular8/Material在mat Select中添加全选触发器,angular,angular-material,Angular,Angular Material,我创建了以下代码: <mat-form-field appearance="outline"> <mat-label>Handler Type</mat-label> <mat-select multiple [(value)]="handlerType"> <mat-option *ngFor="let handlerType of handlerTypeSelect" [va
<mat-form-field appearance="outline">
<mat-label>Handler Type</mat-label>
<mat-select multiple [(value)]="handlerType">
<mat-option *ngFor="let handlerType of handlerTypeSelect" [value]="handlerType">
{{ handlerType.name }}
</mat-option>
<div class="etc-select-action-button">
<button mat-button color="accent" (click)="selectAll()">
<mat-icon>check_box_outline</mat-icon> <span>Select All</span>
</button>
<button mat-button color="accent" (click)="handlerType=undefined; $event.stopPropagation()">
<mat-icon>check_box_outline_blank</mat-icon> <span>Clear All</span>
</button>
</div>
</mat-select>
</mat-form-field>
我想有两个按钮,选择所有和清除所有选定的选项。“全部清除”按钮可以正常工作,但“全部选择”按钮不行。请帮忙。谢谢。单击selectAll方法时,您可以将所有值指定给handletType属性 试试这个:
单击selectAll方法时,可以将所有值指定给handletType属性 试试这个: selectAllselect:NgModel、values、array{ 选择.update.emitvalues; } 取消全部选择:NgModel{ 选择.update.emit[]; } selectAllselect:NgModel、values、array{ 选择.update.emitvalues; } 取消全部选择:NgModel{ 选择.update.emit[];
}能否共享selectAll方法代码?selectAll:void{this.handlerType=this.selectAll;}能否共享selectAll方法代码?selectAll:void{this.handlerType=this.selectAll;}
selectAll(){
this.handlerType = this.handlerTypeSelect;
}