简体   繁体   English

如何在 Angular 分页中隐藏最后一个页码?

[英]How to hide last page number in Angular pagination?

I want to customise my pagination in angular, it should look something like this:我想以角度自定义我的分页,它应该看起来像这样:

<< < 1 2 3... > >> << < 1 2 3... > >>

<< <... 7 8 9... > >> << <... 7 8 9... > >>

Is there any way to achieve this?有什么办法可以做到这一点? I am using ngx-pagination but it is showing the last page number which I don't want.我正在使用 ngx-pagination 但它显示了我不想要的最后页码。 Please help.请帮忙。

Current scenario:当前场景:

< 1 2 3... 20 > < 1 2 3... 20 >

Want this: << < 1 2 3... > >>想要这个: << < 1 2 3... > >>

This could be achieved via custom-template.这可以通过自定义模板来实现。 Here in the official docs example: http://michaelbromley.github.io/ngx-pagination/#/custom-template在官方文档示例中:http: //michaelbromley.github.io/ngx-pagination/#/custom-template

Here in the template, it loops thru the pages array.在模板中,它循环遍历pages数组。

<div *ngFor="let page of p.pages"

Since we don't want the last page, just cut it out of the array由于我们不想要最后一页,只需将其从数组中切出即可

<div *ngFor="let page of p.pages | slice: 0:p.maxSize - 1"

Final result最后结果在此处输入图像描述

Full working code could be found here: https://stackblitz.com/edit/angular-xtusj7?file=app/app.component.ts完整的工作代码可以在这里找到: https ://stackblitz.com/edit/angular-xtusj7?file=app/app.component.ts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Angular 获取 ngx-pagination 中的最后页码 - How to get the last page number in ngx-pagination using Angular 如果页数少于每页的项目数(以角度为单位),如何隐藏分页栏 - How to hide the pagination bar if the number of pages is less than the number of items per page in angular 如何自定义分页以显示从第 1 页到最后一个页码(假设页码为 50)的所有分页页码,不带点(...) - How to customize pagination to display all paginated page number from page 1 to last page number(suppose page number 50) without dots(...) 显示的角度分页控制页码 - Angular pagination control page number to show 角分页,获取当前页码 - Angular Pagination, Get Current Page number 在 ngx 分页上添加第一页和最后一页 - angular 9 - Adding first page and last page on ngx-pagination - angular 9 dataTables - 如何自定义分页类型以显示省略号后跟最后一页编号, - dataTables - How to customize the pagination type to show ellipses followed by last page number, Firestore分页:如何查询最后一页 - Firestore pagination: how to query last page Datatable的分页插件显示最后一个索引页码 - Datatable's pagination plugin shows last index page number 如何获取使用angular在当前页面上分页检索的记录总数? - how to get total number of records retrieved with pagination on the current page using angular?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM