1.引入js文件
<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
2.HTML中代碼的書寫
<td><input type="checkbox" ng-click="updateSelection($event,entity.id)"></td>
$event 代表該行是否被選中
entity.id為自己需要傳入的值
3.js代碼書寫
//定義一個數組
$scope.selectIds=[];
$scope.updateSelection=function($event,id){
if($event.target.checked){
//往數組中加入一個元素
$scope.selectIds.push(id);
}else{
//刪除數組中一個元素
var i=$event.selectIds.indexOf(id);
$scope.selectIds.splice(i,1);
}
}
備注:先定義一個數組 selectIds ,如果選中,則往數組中添加一個元素,否則,移除一個元素。