angular怎么写出带全选反选增删单行单列的表格?并且能够有一个数组是选中的项的数据,不用jq
过去多啦不再A梦2017-05-15 16:52:17
<!DOCTYPE html>
<html lang="ko" >
<머리>
<title>문서</title>
<script src="angular.js"></script>
<script src="checklist.js"></script>
<script src="app.js"></script>
</머리>
<몸>
<input type="checkbox" ng-checked="user.roles.length ==roles.length" ng-click="checkAll()" >전체选/反选
<input type="checkbox" checklist-model="user.roles" checklist-value="role" > {{role.text}}
</body>
</html>
var app = angle.module("app", ["checklist-model"]);
app.controller('Ctrl', function($scope) {
$scope.roles = [
{id: 1, 텍스트: '손님'},
{id: 2, 텍스트: '사용자'},
{id: 3, 텍스트: '고객'},
{ID: 4, 텍스트: '관리자'}
];
$scope.ids = [];
//마법의 结果集合
$scope.user = {
역할: []
};
$scope.checkAll = 함수() {
console.log($scope.user.roles.length == $scope.roles.length)
if($scope.user.roles.length == $scope.roles.length){
$scope.user.roles = [];
$scope.ids = [];
}그밖에{
$scope.user.roles = 각도.복사($scope.roles);
$scope.ids = [];
}
};
$scope.del =기능(){
for($scope.user.roles의 x){
$scope.ids.push($scope.user.roles[x].id);
}
console.log($scope.ids)
};
});