HI all i am using angular material for multi select drop down, i am able to get the
selected values , can any one help to get unchecked value for multi select drop down
You can check following ways,
in component.html
<mat-form-field>
<mat-select placeholder="Toppings" (selectionChange)="onChange($event.value)" multiple>
<mat-option *ngFor="let topping of toppingList" [value]="topping">{{topping}}</mat-option>
</mat-select>
</mat-form-field>
and in component.ts
toppingList: string[] = ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
selectedList: any = []; // store selected options here
onChange(event) {
let missing = null;
for (let i = 0; i < this.selectedList.length; i++) {
if (event.indexOf(this.selectedList[i]) == -1) missing = this.selectedList[i]; // Current[i] isn't in prev
}
if (missing)
alert(missing);
this.selectedList = event;
}
here is Stackblitz demo
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.