Md Shifatul Islam Md Shifatul Islam - 4 months ago 13x
Javascript Question

Check all check box and send all updated status as a Object [Angular Js]

I have used this

<div class="col-sm-12">
<input type="checkbox" onclick="for(c in document.getElementsByName('rfile')) document.getElementsByName('rfile').item(c).checked = this.checked" >Check All </button>

<tr role="row">
<th>Student ID</th>
<tr ng-repeat="result in searchResults">
<td ><a href="#/Attendance/edit/{{}}">{{result.studentId}}</a>
<td ><input type="checkbox" name="rfile" ng-model="result.status" /> {{result.status}}</td>
<button ng-click="save()">Save</button>




It is perfectly checking all the checkbox but it is not updating the status.

what should i do.. When i click individual checkbox for updating it works perfectly.

I m beginner please dont give down vote.


You must use ng-click or ng-change to manipulate your scope data and put all result status to true (or false).

Here a plunker to illustrate it :

See your checkbox to check all

<input type="checkbox" ng-click="onCheckAll()" ng-model="checkAll">Check All