我只能搜索当前页面记录,但是我需要搜索从服务器返回的整个记录集。这是我的代码:
<tr ng-repeat="brt in $parent.visibleBrtList = (currBrtList
| orderBy: state.orderBy : state.reverseOrderByDirection
| filter: pageFilter(state.page, state.itemsPerPage)
| filter: searchKeyword) ">
我也尝试过这样修改它:
<tr ng-repeat="brt in currBrtList
| filter: pageFilter(state.page, state.itemsPerPage)
| filter: searchKeyword">
currBrtList有200条记录,itemsPerPage为10。
这是pageFilter函数:
$scope.pageFilter = function() {
var from = $scope.state.page * $scope.state.itemsPerPage;
var to = from + $scope.state.itemsPerPage;
return function(item, index) {
return index >= from && index < to;
}
}
答案 0 :(得分:0)
使用limitTo
过滤器进行分页:
<tr ng-repeat="brt in currBrtList
| orderBy: state.orderBy : state.reverseOrderByDirection
| filter: searchKeyword
̶|̶ ̶f̶i̶l̶t̶e̶r̶:̶ ̶p̶a̶g̶e̶F̶i̶l̶t̶e̶r̶(̶s̶t̶a̶t̶e̶.̶p̶a̶g̶e̶,̶ ̶s̶t̶a̶t̶e̶.̶i̶t̶e̶m̶s̶P̶e̶r̶P̶a̶g̶e̶)̶
| limitTo: state.itemsPerPage : state.page*state.itemsPerPage" >
第一个参数是limit
;第二个是begin
。
还请确保在分页之前过滤。
有关更多信息,请参见