in normal html form, you submit a form and you have access to array of check box in server side , but in angular there is no form post , and we have view model , what we have to do is to post Id of selected entities to server side method, here is how normally handle selected check box for batch operation
here is my check box in ng-repeat loop
<tr ng-repeat="meeting in vm.meetings" class="odd gradeX">
<td>
<input type="checkbox" class="group-checkable icheck" ng-click="vm.selectMeeting(meeting)"/>
</td>
and here is my function in angularjs controller
function selectMeeting(meeting) {
var index = -1;
//check to see if user has check or uncheckd the check box
for (var i = 0; i < vm.meetingSelected.length; i++) {
if (vm.meetingSelected[i].indexOf(meeting.id) > -1) {
index = i;
}
}
//if checked add it to vm.meetingSelected array
if (index == -1) {
vm.meetingSelected.push(meeting.id)
}
//if unchecked remove it form vm.meetingSelected array
else {
vm.meetingSelected.splice(index, 1);
}
}
i Dont like this code actully , i think there should be better way to select checked check box in angularjs.
any suggestion for better way to handle check box in angularjs ? thanks