0
votes

I tried to ngModel bind value in mat-select dropdown.I have some value in options ex: A - A/C Loss, B - BURGLARY. Once i checked option checkbox i need to bind only A,B remove A/C Loss and BURGLARY.

This is options value example: enter image description here This is ngModel bind value example: enter image description here Need to exactly result in ngModel: A,B,CF,CI,CM,CR

Code Example:

<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>
1

1 Answers

0
votes

try this

<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>