AngularJS - ngRepeat & checkboxes
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
<div ng-controller="MyCtrl">
<table class='table table-bordered'>
<tr ng-repeat="appObj in myAppObjects">
<td>{{appObj.id}}
<input type="checkbox" ng-checked = 'appObj.checked' ng-click="checked($index, $event)"></td>
<td>test</td>
</tr>
</table>
</div>
JavaScript
function MyCtrl($scope) {
$scope.myAppObjects = [
{id: 1, checked:false},{id: 2, checked:false},{id: 3, checked:false},{id: 4, checked:false},{id: 5, checked:false},{id: 6, checked:false},{id: 7, checked:false}
];
$scope.checked = function($index, $event){
console.log($index, $event, $event.shiftKey, $scope.lastChecked);
if($scope.lastChecked && $event.shiftKey){
for(i=$scope.lastChecked; i<$index;i++){
$scope.myAppObjects[i].checked=true;
}
}
$scope.myAppObjects[$index].checked=true;
$scope.lastChecked = $index;
}
}