-4

I want to loop through this column of my mat-table to find which rows are checked and then push that row data into an array.

<td mat-cell *matCellDef="let row">
    <mat-checkbox (click)="$event.stopPropagation()" (change)="pushRowToArray($event, row)" (change)="$event ? selection.toggle(row) : null"
      [checked]="selection.isSelected(row)">
    </mat-checkbox>
</td>
Iñigo
  • 1,877
  • 7
  • 25
  • 55
Kourosh
  • 11
  • 5

1 Answers1

0

I would make the checkbox call a function and add it to an array in there.

Like this:

<input type="checkbox"  id="matCheckBox" (change)="yourfunc($event)"/>

and make the func like

yourfunc(e) {
   if(e.target.checked){
      this.array.push(e.target);
   }else{
     this.array = this.array.filter(obj => obj !== e.target);
   }
}
Nick Alexander
  • 361
  • 2
  • 5
  • 21