【问题标题】:Angular Pagination - Filtered results not updating total-itemsAngular Pagination - 过滤结果不更新总项目
【发布时间】:2015-02-25 12:01:12
【问题描述】:

我有两个过滤器,一个用于分页,一个用于搜索查询。它首先搜索,然后对结果进行分页。

这里是html:

    <table class="table table-striped">
    <tbody>
        <tr ng-repeat="pot in (filteredPots = (pots | search:potQuery | paginate:currentPageNumber.pots:itemsPerPage))">
            ...
        </tr>
    </tbody>
</table>
<pagination ng-model="currentPageNumber.pots" ng-change="paging(pots)" items-per-page="{{itemsPerPage}}" total-items="filteredPots.length" class="pagination-sm"></pagination>

据我了解,这可以正常工作(我可以添加 {{ filteredPots.length }} 并显示值 10)。

我想要做的是将 total-items 值作为总数组长度(即没有将其限制为 itemsPerPage 的分页)。

非常感谢任何帮助,谢谢!

【问题讨论】:

    标签: angularjs pagination angularjs-ng-repeat angularjs-filter


    【解决方案1】:

    想通了...经过大量的试验和错误。

    Html 更新为:

        <table class="table table-striped">
        <tbody>
            <tr ng-repeat="pot in (filteredPots = (searchedPots = (pots| search:potQuery) | paginate:currentPageNumber.games:itemsPerPage))">
                ...
            </tr>
        </tbody>
    </table>
    <pagination ng-model="currentPageNumber.pots" ng-change="paging(pots)" items-per-page="{{itemsPerPage}}" total-items="searchedPots.length" class="pagination-sm"></pagination>
    

    发生了什么变化?我不是用两个单独的过滤器过滤数组pots,而是在过滤器search:potQuery上过滤数组pots并将结果数组保存为searchedPots,然后第二个过滤器使用searchedPots作为数组,并将结果保存为filteredPots(未使用)。

    然后我在分页之前将搜索到的罐子的长度设为searchedPots

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 2014-12-19
      • 1970-01-01
      相关资源
      最近更新 更多