![](/img/trans.png)
[英]how to get total number of records retrieved with pagination on the current page using angular?
[英]Angular Pagination, Get Current Page number
我正在尝试获取当前页面的分页。 这是app.component.html中的代码:
<ngb-pagination [collectionSize]="500" [(page)]="page" (click)="showPageIndex(page)" aria-label="Default pagination" ></ngb-pagination>
<p>current page is {{page}}</p>
在app.component.ts中:
public page = 1;
showPageIndex(pageIndex){
this.page = pageIndex;
console.log(this.page);
}
当我单击页面(例如第12页)时,得到的结果为“ 1”。 当我再次单击时,得到的结果为“ 12”(正确的结果)。
然而,
当前页面是{{page}}
,显示正确的页面。似乎在触发onclick时,它将获取当前页面的值(而不是单击完成后的页面)。
这种方法有什么问题吗? 在这种情况下,我应该手动编写用于分页的代码,而不是使用库吗?
感谢您的支持。
谢谢,
尝试使用(pageChange)=“ onPageChange(currentPage)而不是(click)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.