gpt4 book ai didi

javascript - 如何仅在 AngularJS 中选中所有复选框中的筛选复选框?

转载 作者:行者123 更新时间:2023-11-29 23:46:41 24 4
gpt4 key购买 nike

我有这个 Angular 表:

$scope.customers = [{
first_name: "Oded",
last_name: "Taizi",
id: 1,
type_link: 2
}, {
first_name: "Ploni",
last_name: "Almoni",
id: 2,
type_link: 2
}, {
first_name: "Fred",
last_name: "Dyllan",
id: 3,
type_link: 2
}, {
first_name: "Dan",
last_name: "Omer",
id: 4,
type_link: 4
}, {
first_name: "Amir",
last_name: "Maly",
id: 5,
type_link: 3
}, {
first_name: "Noa",
last_name: "Levy",
id: 6,
type_link: 3
}];

还有这个函数:

 $scope.checkAll = function(isCheck) {
angular.forEach($scope.customers, function(cust) {
cust.select = isCheck.selectAll;
});
};

我想通过免费搜索和分组来过滤这些数据。这对我有用。
我的问题是单击全选复选框时,它会选中所有复选框,即使在过滤时也是如此

我只想检查所有筛选的行。

这是我的 jsfiddle .
尝试通过选择框进行过滤。

最佳答案

您可以引用过滤后的数组:

<tr ng-repeat="cust in filteredCustomers = (customers | orderBy:orderByField:reverseSort | 
filter :searchInput | filter: {type_link: typesModel}) ">

可以直接作为 $scope.filteredCustomers 访问。

现在,不检查所有客户,只检查来自 $scope.filteredCustomers 的客户。喜欢:

$scope.checkAll = function(isCheck) {
angular.forEach($scope.filteredCustomers, function(cust) {
cust.select = isCheck.selectAll;
});
};

working fiddle | fiddle$scope.filteredCustomers

关于javascript - 如何仅在 AngularJS 中选中所有复选框中的筛选复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43755445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com