我尝试在mat-select下拉列表中使用ngModel绑定值。我在选项ex中有一些值:A - A / C Loss,B - BURGLARY。 一旦我选中了复选框,我只需要绑定A,B就可以删除A / C Loss和BURGLARY。
这是选项值示例: 这是ngModel绑定值示例: 需要精确地导致ngModel:A,B,CF,CI,CM,CR
代码示例:
<mat-select placeholder="Select Events" [formControl]="selectEventitems" [(ngModel)]="selectedEventValue" (change)="onEventsChange($event)" (focus)="onEventfocus($event)" multiple>
<mat-option class="select-all" value="SelectAll">Select All</mat-option>
<mat-option *ngFor="let event of getAllEvents" [value]="event.eventrpt_id">{{event.eventrpt_id}} - {{event.descr}}</mat-option>
</mat-select>
答案 0 :(得分:0)
试试这个
<mat-select placeholder="Select Events" [formControl]="selectEventitems" [(ngModel)]="selectedEventValue" (change)="onEventsChange($event)" (focus)="onEventfocus($event)" multiple>
<mat-option class="select-all">Select All</mat-option>
<mat-option *ngFor="let event of getAllEvents" [value]="event.eventrpt_id">{{event.eventrpt_id}} - {{event.descr}}</mat-option>
</mat-select>