过去多啦不再A梦2017-05-15 16:52:17
<! DOCTYPE html>
<頭>
<標題>文件標題>
<腳本 src="angular.js">腳本>
頭>
<身體>
全選/反選
{{角色.text}}
身體>
var app = angular.module("app", ["checklist-model"]);
app.controller('Ctrl', function($scope) {
$scope.roles = [
{id: 1, text: '客人'},
{id: 2, text: '使用者'},
{id: 3, text: '客戶'},
{id: 4, text: 'admin'}
];
$scope.ids = [];
//選擇結果集合
$scope.user = {
角色:[]
};
$scope.checkAll = function() {
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 = angular.copy($scope.roles);
$scope.ids = [];
}
};
$scope.del =函數(){
for(x in $scope.user.roles){
$scope.ids.push($scope.user.roles[x].id);
}
console.log($scope.ids)
};
});