我有这个例子: https://jsfiddle.net/3noebzgr/1/
一切正常,除非我按球衣编号过滤我无法更新分页。因此,如果我为球衣号码1-3过滤,则球衣1位于第1页,球衣2位于第2页,球衣3位于第4页,第3页则为空。我希望该表重新分页以在一个页面上具有筛选列表(或更多取决于项目数)。 这是我的分页功能:
$scope.paginate = function(value) {
var begin, end, index;
begin = ($scope.currentPage - 1) * $scope.numPerPage;
end = begin + $scope.numPerPage;
index = $scope.players.indexOf(value);
return (begin <= index && index < end);
};
这是应用的地方:
<tr ng-repeat="player in players | orderBy:sortType:sortReverse | filter:byRange('Number', minNum.Number, maxNum.Number) | filter:paginate">
<td>{{ player.Name }}</td>
<td>{{ player.Number }}</td>
<td>{{ player.Position }}</td>
<td>{{ player.Team }}</td>
</tr>
过滤器:
<select name="minNum" ng-model="minNum" ng-options="player.Number for player in players | orderBy:'Number'">
<option value="">All</option>
</select>
和
<select name="maxNum" ng-model="maxNum" ng-options="player.Number for player in players | orderBy:'Number'">
<option value="">All</option>
</select>
我已经尝试过其他堆栈溢出建议,但到目前为止还没有。>
答案 0 :(得分:0)
单击maxnumber时,将$ scope.numPerPage重新设置为等于$ scope.players.length,以使每页的num数等于播放器长度。感谢
$scope.paginate = function(value) {
var begin, end, index;
begin = ($scope.currentPage - 1) * $scope.numPerPage;
end = begin + $scope.numPerPage;
index = $scope.players.indexOf(value);
if ($scope.maxNum !== undefined) {
$scope.numPerPage = $scope.players.length;
}
return (begin <= index && index < end);
};