xml地图|网站地图|网站标签 [设为首页] [加入收藏]

取消全选

来源:http://www.ccidsi.com 作者:集成介绍 人气:197 发布时间:2019-05-29
摘要:!--html-- 全选、撤除全选、单选,撤销全选单选 !--html-- table class="table1" thead tr th input id="flag" type="checkbox" ng-model="select_all"ng-change="selectAll()" /th th合同编号/th th合同名称/th th分配公司/th

<!--html-->

全选、撤除全选、单选,撤销全选单选

<!--html-->

<table class="table1">
<thead>
<tr>
<th> <input id="flag" type="checkbox" ng-model="select_all" ng-change="selectAll()"> </th>
<th>合同编号</th>
<th>合同名称</th>
<th>分配公司</th>
<th>更新时间</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="list in lists">
<td> <input type="checkbox" ng-model="list.checked" ng-change="selectOne()"> </td>
<td>{{list.contractnum}}</td>
<td>{{list.template.name}}</td>
<td>{{list.office.name}}</td>
<td>{{list.updateDate}}</td>
</tr>
</tbody>
</table>

 

<!--js-->

 

$scope.checked = [];//用来存放在选中项的id
$scope.select_all = “”;
$scope.list = {
checked: “”
}

//全选
$scope.selectAll = function() {
if($scope.select_all) {
$scope.checked = [];
angular.forEach($scope.lists, function(i) {
i.checked = true;
$scope.checked.push(i.id);
})
} else {
angular.forEach($scope.lists, function(i) {
i.checked = false;
$scope.checked = [];
})
}
};

//单选
$scope.selectOne = function() {
angular.forEach($scope.lists, function(i) {
var index = $scope.checked.indexOf(i.id);
if(i.checked && index === -1) {
$scope.checked.push(i.id);
} else if(!i.checked && index !== -1) {
$scope.checked.splice(index, 1);
};
})

if($scope.lists.length === $scope.checked.length) {
$scope.select_all = true;
} else {
$scope.select_all = false;
}
}

 

!--html-- table class="table1" thead tr th input id="flag" type="checkbox" ng-model="select_all" ng-change="selectAll()" /th th合...

<table class="table1">
<thead>
<tr>
<th> <input id="flag" type="checkbox" ng-model="select_all" ng-change="selectAll()"> </th>
<th>合同编号</th>
<th>合同名称</th>
<th>分配公司</th>
<th>更新时间</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="list in lists">
<td> <input type="checkbox" ng-model="list.checked" ng-change="selectOne()"> </td>

<td>{{list.contractnum}}</td>

<td>{{list.template.name}}</td>

<td>{{list.office.name}}</td>

<td>{{list.updateDate}}</td>
</tr>
</tbody>
</table>

 

本文由68399皇家赌场发布于集成介绍,转载请注明出处:取消全选

关键词: 68399皇家赌场

上一篇:在Linux环境下安装并配置jdk

下一篇:没有了

最火资讯