首页 > 解决方案 > Primeng 表获取当前显示的行数

问题描述

我正在使用primeng表并为其启用了分页。我试图向用户显示当前显示的记录数和总记录数。类似于显示 200 个条目中的 1-20 个。但是,问题在于,如果记录不是 20 的倍数,则最后一页显示 194 个条目中的 180 到 200 个。我希望它是 194 个条目中的 180 到 194 个。请帮忙。提前致谢。

这是我的模板

<ng-template pTemplate="paginatorleft" let-state>
    <span>Showing {{(state.page * state.rows) + 1}} to {{state.rows * (state.page + 1)}} of {{state.totalRecords}} entries
</ng-template>

标签: htmlangularprimeng

解决方案


为什么不只是更新条件?

(state.totalRecords > (state.rows * (state.page + 1))) ? state.rows * (state.page + 1) : state.totalRecords

代替

 state.rows * (state.page + 1)

推荐阅读