使用角度材质从垫列表中删除在角度2中不起作用的选定项目 [英] Deleting selected items from mat-list not working in angular 2 using angular material

查看:81
本文介绍了使用角度材质从垫列表中删除在角度2中不起作用的选定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用角度材料在角度2中实现了一个简单表.实现了两种方法,第一种是 transferSelectedRows ,该方法在从表中选择行时会将行数据推送到选定行"部分.

I have implemented a simple table in angular 2 using angular material ..Implemented two methods , first is transferSelectedRows which on selecting rows from table pushes the row data to Selected Rows section.

第二种方法是 removeSelectedRows ,在其中选择行并单击 Remove Selected Rows (删除所选行)按钮应删除相应的列表项.但是我无法从垫子选择列表 ...

Second method is removeSelectedRows where on selecting the rows and clicking Remove Selected Rows button should delete the corresponding list items.But I am unable to delete the items from the mat-selection-list...

有人可以帮我吗...!

Can anybody please help me out ...!

请在此处访问我的示例示例.. https://stackblitz .com/edit/angular-nwjqsj-au6ho8?file = index.html

please access my sample example here ..https://stackblitz.com/edit/angular-nwjqsj-au6ho8?file=index.html

推荐答案

您可以修改removeSelectedRows()以过滤表中的选定项目:

You can modify your removeSelectedRows() to filter the selected items in the table:

removeSelectedRows() {
    this.selection.selected.forEach(item => {
      this.selectedRows = this.selectedRows.filter(element => element !== item);
    });
  }

这篇关于使用角度材质从垫列表中删除在角度2中不起作用的选定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆