Angular Material 多选在隐藏时获取选定值

标签 angular angular-material material-design multi-select

场景:

  • 我有一个 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

申请代码: https://stackblitz.com/edit/angular-values-access-after-dropdown-close?file=src/app/app.component.html

方法:

  • 保留一个变量来存储多选值。
    使用openedChange事件作为(openedChange)="comboChange($event)”,并将所选值存储到数组或不同的变量中。
    如果下拉列表关闭,事件值为 false,所以我使用了它在演示代码中。
  • 此外,mat-select[formControl]="toppings" 一起使用,因此在任何其他方法中,您可以使用 访问它的值>this.toppings.value,它将返回一个包含选定值的数组。

关于 Angular Material 多选在隐藏时获取选定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53275566/

相关文章:

Android 全屏对话框 fragment ,如日历应用程序

angular - 选择选项不适用于 Angular 4 中的 ng-model

angular - 无法使用组件@ncstate/sat-popover 绑定(bind)到属性 'satPopoverAnchorFor'

html - 将 HTML 内容添加到 Angular Material $mdDialog

css - 如何应用条件CSS?

mobile - Flutter:根据验证更改状态

javascript - 如何在我的 React 网站中使用 float 按钮?

javascript - 一旦在 Angular 2 中打开,如何将焦点设置在模态元素上?

css - Angular 7 : Why class style is not applied to DOM component?

javascript - 将数据从登录路由组件传递到导航菜单组件