In my Typescript file, I have the following HTML template:
<table id="tab" class="table" align="center" border="1">
<thead>
<tr id="header">
<th><input type="checkbox" (change)="checkAll(this)"
></th>
<th>Name</th>
<th>Age</th>
<th>Gender</th>
<th>City</th>
<th>Surname</th>
</tr>
</thead>
<tbody class="trclass">
<tr>
<td><input type="checkbox" aria-label="..."></td>
<td>Ronak</td>
<td>19</td>
<td>Male</td>
<td>Goa</td>
<td>Kesha</td>
</tr>
</tbody>
</table>
And here is the function inside the class:
checkAll(ele) {
var checkboxes = document.getElementsByTagName('input');
if (ele.checked) {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
console.log(checkboxes[i].value);
checkboxes[i].checked = true;
}
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
//console.log("Here inside function");
}
But this still doesn't work.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.