从后端获取数组如下:
$scope.arr = [
{
selected:true;
}
{
selected:true;
}
{
selected:true;
}
]
$scope.select = function(){
// 如何在不调用后端接口的情况下,修改ng-repeat中ng-checked的状态实现全选和反选?
}
<ul>
<li ng-repeat="i in arr">
<input type="checkbox" ng-checked="i.selected">
</li>
</ul>
<input type="checkbox" ng-click="select()">
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这里边的反选说的是在不全选的情况下,选中变为未选中,未选中变选中,不是清空!!!
清空的话要复杂一点。
http://stackoverflow.com/questions/12648466/how-can-i-get-angular-js-checkboxes-with-select-unselect-all-functionality-and-i