I am working on table. one column of table has checkboxes. When I am clicking one checkbox all checkbox of that column getting checked.
This is my code
<td>
<label class="container">
<input type="checkbox" [(ngModel)]="theCheckbox" data-md-icheck (change)="toggleVisibility($event)"/>
Checkbox is <span *ngIf="marked">checked</span><span *ngIf="!marked">unchecked</span>
</label>
</td>
toggleVisibility function is empty
toggleVisibility(data)
{
}
How can I solve this issue?
Try something like this:
<table >
<thead>
<tr>
<th *ngFor="let head of headElements" scope="col">{{head}} </th>
</tr>
</thead>
<tbody>
<tr *ngFor="let el of elements;let index = index;">
<th scope="row">{{el.id}}</th>
<td>{{el.first}}</td>
<td>{{el.last}}</td>
<td>
<input type="checkbox" [(ngModel)]="el.checked" >
<span *ngIf="el.checked" >checked</span>
</td>
</tr>
</tbody>
</table>
https://stackblitz.com/edit/angular-mnrmpp?file=src/app/app.component.html
Hope it helps!
How can I get selected record, as per my code in .ts file. Thanks
stackblitz.com/edit/angular-tmd8r9?file=src/app/…