gpt4 book ai didi

javascript - AngularJS 中的分页和过滤不稳定

转载 作者:行者123 更新时间:2023-11-28 06:18:25 26 4
gpt4 key购买 nike

我有一个动态表,显示来自用户数组的数据。我想根据所有字段进行过滤,它们不是特定的,它们取决于用户数组。用户数组也可以更改。

 $scope.usersTable = new ngTableParams({
page: 1,
count: 10
}, {
total: $scope.users.length,
getData: function($defer, params) {
debugger;

$scope.data = params.sorting() ? $filter('orderBy')($scope.users, params.orderBy()) : $scope.users;
$scope.data = params.filter() ? $filter('filter')($scope.users, params.filter()) : $scope.users; // in there this data must be filtered but it is not
params.total($scope.data.length);

$scope.data = $scope.data.slice((params.page() - 1) * params.count(), params.page() * params.count());
$defer.resolve($scope.data);
}
});
$scope.cols = Object.keys($scope.users[0]);
<input type="text" class="form-control" id="src_product " placeholder="Aramak İstediğiniz Ürün Alanını Giriniz" ng-model="src_product" ng-change="getProducts()">

<table ng-table="usersTable" id="productTable" class="table table-striped" show-filter="true">

<tr>
<th class=" bg-aqua-gradient text-center" ng-repeat="column in cols">{{column}}</th>
<th class="bg-aqua-gradient ">Adet</th>
</tr>

<tbody ng-form="labelPrintTableForm">
<tr ng-repeat="row in data | filter: src_product">

<td class="highlighted" id="{{row.id}}_{{column}}" ng-class="{'unhighlighted':unselectedCells.indexOf(row.id + '_' + column) != -1}" ng-repeat="column in cols" onclick=" selectcells(this)">
{{row[column]}}
</td>
<td class="highlighted">
<input class=" input-group-sm " type="number" style="width: 100%; height: 30px !important" name=" adet" value="0" ng-minlength="0" required>
<span ng-show="labelPrintTableForm.adet.$error.required">Adet alanı En az 0 olar</span>
</td>


</tr>
</tbody>

</table>

这不是进行过滤。我做错了什么?

最佳答案

我解决问题。我写

 `$scope.data = params.filter() ? $filter('filter')($scope.users, $scope.src_product) : $scope.users;`

而不是

$scope.data = params.filter() ? $filter('filter')($scope.users, params.filter()) : $scope.users; 

关于javascript - AngularJS 中的分页和过滤不稳定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35744438/

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