Skip to content Skip to sidebar Skip to footer

Removing Data From Array Using Checkbox In Angular?

I have a mat-table with some data generated through an API, here's a snippet for example:

Solution 1:

My solution was pretty simple. I added an event to the function call - like this.

<tsl-checkbox #myCheckbox [checked] (change)="setHomeProcesses(execution, $event)"></tsl-checkbox>
reprocessHomeProcesses(exe, event: any) {
    if (event.checked) {
      this.reprocesses.push(exe)
    } else {
      var index = this.reprocesses.indexOf(exe)
      if (index > -1) {
        this.reprocesses.splice(index, 1);
      }
    }
  }

This works as needed here.


Post a Comment for "Removing Data From Array Using Checkbox In Angular?"