场景:
- 我有一个 Angular Material 多选过滤器
待办事项:
我想在隐藏的下拉列表中获取选定的值..
I googled and tried to find the doc but could not found any ref to add hide event to miltiselect
最佳答案
Demo where multi-select values are available after closed mat-select dropdown
方法:
- 保留一个变量来存储
多选
值。
使用openedChange
事件作为(openedChange)="comboChange($event)”
,并将所选值存储到数组或不同的变量中。
如果下拉列表关闭,事件值为false
,所以我使用了它在演示代码中。 - 此外,
mat-select
与[formControl]="toppings"
一起使用,因此在任何其他方法中,您可以使用访问它的值>this.toppings.value
,它将返回一个包含选定值的数组。
关于 Angular Material 多选在隐藏时获取选定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53275566/