如何使用dir-paginate将currentpage设置为last

时间:2017-01-20 00:55:30

标签: angularjs

我正在使用:https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination

我希望在列表中添加新元素后,使我的currentPage成为最后一页。 我尝试使用像这样的paginationService:

paginationService.setCurrentPage('ID', Math.ceil(paginationService.getCollectionLength("ID")/ITEMSPERPAGE));

然而,问题是收集在几毫秒后更新,这意味着' getCollectionLength'函数不会返回correctValue。

1 个答案:

答案 0 :(得分:1)

我决定尝试使用角度的$ timeout模块,因为它有意义dir-paginate将使用相同的点击角度使用来更新。 它正如预期的那样工作,代码现在是:

addr = page_address(page)

只需确保模块导入中的$ timeout和ng-controller的函数参数。愚蠢的错误,但我忘记了。