我只是使用角度材料进行多选下拉,我能够得到选择的值,任何一个可以帮助获得多选下拉列表的未选中值
你可以检查以下方式,
在 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>
并在 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; }
这是Stackblitz演示
1 回答
你可以检查以下方式,
在 component.html
并在 component.ts
这是Stackblitz演示