可以使用AngularJS的ng-model指令结合Bootstrap的表格来实现全选复选框功能。以下是一个示例代码:
HTML代码:
Name
Email
{{user.name}}
{{user.email}}
JavaScript代码:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.users = [
{name: 'John', email: 'john@example.com', selected: false},
{name: 'Jane', email: 'jane@example.com', selected: false},
{name: 'Bob', email: 'bob@example.com', selected: false}
];
$scope.selectAll = false;
$scope.toggleAll = function() {
angular.forEach($scope.users, function(user) {
user.selected = $scope.selectAll;
});
};
});
这个示例中,使用了ng-model指令来绑定全选复选框和每个用户的复选框。当全选复选框的状态改变时,ng-change指令会调用toggleAll函数来改变所有用户的复选框状态。