0
votes

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.

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 ...!

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

Below shown is the output of my sample angular 2 app.

enter image description here

1
@Safiyya... can you please check this out .....stackblitz.com/edit/…Heena
From what I can see, when you select items from the right column to delete them, your this.selection.selected is empty. That might be a good start for debugging your app.filipbarak

1 Answers

0
votes

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);
    });
  }