Let's say I have this table:
I'd like to check the top checkbox and have all them checked, or uncheck it then have all of them unchecked.
In JQuery, something like this:
$("#mytable tbody :checkbox").prop('checked', true);
You can also find a checkbox and applied change to it.
I just don't see how to establish 2-ways binding with those checkboxex as they are dynamically constructed.
<tr *ngFor="let tRow of initConsView.bodyData">
<td *ngFor="let col of tRow">
<input *ngIf="col.key == 'Id'"
type="checkbox" [attr.id]="'ck_' + col.value"
(change)="onChecked($event, col.value)" />
<span *ngIf="col.key != 'Id'">{{ col.value }}</span>
</td>
</tr>
Do I need to keep track of each chekbox through an array of ids, representing each checkbox?
With one checkbox, I could do something like this:
[checked]="someValueInTheTypeScriptFile"
I've though about using nested component containing a checkbox. Unfortunately, the problem remains the same. In fact, it will be easy to send data from component to container. However, targeting some or all the checkbox is what's a little challenging.
Thanks for helping
