简体   繁体   English

如何使用 Angular 获取 ngx-pagination 中的最后页码

[英]How to get the last page number in ngx-pagination using Angular

How can we work with Custom templates in ngx-pagination, and get the first and last button worked when clicked, I have used pagination-template to achieve the same...我们如何在 ngx-pagination 中使用自定义模板,并在单击时让第一个和最后一个按钮起作用,我使用 pagination-template 来实现相同的...

how can I find the last page number dynamically?,我怎样才能动态找到最后的页码?,

<ul class="meal-list">
  <li *ngFor="let meal of meals | paginate: config">
    {{ meal.id }}
    {{ meal.name }}
  </li>
</ul>

<pagination-template
  #p="paginationApi"
  [id]="config.id"
  (pageChange)="config.currentPage = $event"
>
  <div class="custom-pagination">
    <div class="pagination-first" [class.fade]="p.isFirstPage()">
      <a *ngIf="!p.isFirstPage()" (click)="p.setCurrent(1)">First</a>
    </div>
    <div class="pagination-previous" [class.disabled]="p.isFirstPage()">
      <a *ngIf="!p.isFirstPage()" (click)="p.previous()"> < </a>
    </div>

    <div
      *ngFor="let page of p.pages"
      [class.current]="p.getCurrent() === page.value"
    >
      <a
        (click)="p.setCurrent(page.value)"
        *ngIf="p.getCurrent() !== page.value"
      >
        <span>{{ page.label }}</span>
      </a>
      <div *ngIf="p.getCurrent() === page.value">
        <span>{{ page.label }}</span>
      </div>
    </div>

    <div class="pagination-next" [class.disabled]="p.isLastPage()">
      <a *ngIf="!p.isLastPage()" (click)="p.next()"> > </a>
    </div>
    <div class="pagination-last" [class.disabled]="p.isLastPage()">
      <a *ngIf="!p.isLastPage()" (click)="p.setCurrent(4)">Last</a>
    </div>
  </div>
</pagination-template>

You can achieve that using setCurrent and getLastPage together您可以一起使用setCurrentgetLastPage来实现

example例子

<div class="pagination-last" [class.disabled]="p.isLastPage()">
  <a *ngIf="!p.isLastPage()" (click)="p.setCurrent(p.getLastPage())">Last</a>
</div>

暂无
暂无

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

相关问题 在 ngx 分页上添加第一页和最后一页 - angular 9 - Adding first page and last page on ngx-pagination - angular 9 如何为 Angular 中的表格正确实现 ngx-pagination? - How to properly implement ngx-pagination for tables in Angular? 如何在 ngx-pagination 中制作过滤器 - How make filter in ngx-pagination 如何在 Angular 分页中隐藏最后一个页码? - How to hide last page number in Angular pagination? 如何使用 ngx-pagination 在 ionic4 app 中对数据进行分页? - how to paginate data in ionic4 app with ngx-pagination? 我如何在 ngx-pagination 的数组上使用 ngFor* 将分页控制数字(1 2 3)更改为其他值,例如“Anything1 Anything2 ...”? - How an i change the pagination-control numbers(1 2 3) to other values like 'Anything1 Anything2 …' using ngFor* on array in ngx-pagination? 如何获取使用angular在当前页面上分页检索的记录总数? - how to get total number of records retrieved with pagination on the current page using angular? 角分页,获取当前页码 - Angular Pagination, Get Current Page number 如何自定义分页以显示从第 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表分页中获取增量序列号 - How to get incremental serial number in Angular table pagination
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM