My mat-table contains data and checkboxes. The checkboxes should only be checked when the element.select
property is true. However, when I use [(ngModel)]="element.select"
, all the checkboxes end up getting checked. Below you can find the code snippet:
<td mat-cell *matCellDef="let element">
{{element.select}}
<mat-checkbox [(ngModel)]="element.select" formControlName="select" (change)="checkIfAllSelected()"></mat-checkbox>
</td>
I'm struggling to identify what's wrong with this code. Any insights would be appreciated.
I have also attempted to use property binding like [checked]="model.select"
, but unfortunately, it doesn't seem to work either.
The goal is to have the checkbox checked only when element.select
is set to true.