Pagination分页器

分隔长列表,每次只加载一个页面。

规则

  • 当加载/渲染所有数据将花费很多时间或者流量时使用

代码演示

基本用法

基本的分页器。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'demo-pagination-basic',
  4. template: `
  5. <div class="pagination-container">
  6. <p class="sub-title">Button with text</p>
  7. <Pagination [total]="5" [current]="1" [locale]="locale"></Pagination>
  8. <p class="sub-title">Button with text and icon</p>
  9. <Pagination
  10. class="custom-pagination-with-icon"
  11. [total]="5"
  12. [current]="1"
  13. [locale]="{ prevText: localeLeft, nextText: localeRight }"
  14. >
  15. </Pagination>
  16. <p class="sub-title">Hide number</p>
  17. <Pagination [simple]="true" [total]="5" [current]="1" [locale]="locale"></Pagination>
  18. <p class="sub-title">Show number only</p>
  19. <Pagination [mode]="'number'" [total]="5" [current]="3"></Pagination>
  20. <p class="sub-title">Point style</p>
  21. <Pagination [mode]="'pointer'" [total]="5" [current]="2" style="marginBottom: '16px'"></Pagination>
  22. <ng-template #localeLeft>
  23. <span class="arrow-align"><Icon type="left"></Icon>上一步</span>
  24. </ng-template>
  25. <ng-template #localeRight>
  26. <span class="arrow-align">下一步<Icon type="right"></Icon></span>
  27. </ng-template>
  28. </div>
  29. `,
  30. styles: [
  31. `
  32. .pagination-container {
  33. margin: 0 15px;
  34. }
  35. .custom-pagination-with-icon .am-pagination-wrap-btn-prev .am-button-inline {
  36. padding-left: 0;
  37. padding-right: 10px;
  38. }
  39. .custom-pagination-with-icon .am-pagination-wrap-btn-next .am-button-inline {
  40. padding-left: 10px;
  41. padding-right: 0;
  42. }
  43. .arrow-align {
  44. display: flex;
  45. align-items: center;
  46. }
  47. .sub-title {
  48. color: #888;
  49. font-size: 14px;
  50. padding: 30px 0 18px 0;
  51. }
  52. `
  53. ]
  54. })
  55. export class DemoPaginationBasicComponent {
  56. locale = {
  57. prevText: 'Prev',
  58. nextText: 'Next'
  59. };
  60. constructor() {}
  61. }

Pagination分页器 - 图1

API

参数说明类型默认值
[mode]形态‘button’ | ‘number’ | ‘pointer’‘button’
[current]当前页号number1
[total]数据总数number0
[simple]是否隐藏数值booleanfalse
[disabled]禁用状态booleanfalse
[locale]国际化, 可以覆盖全局LocaleProvider的配置{prevText: string | TemplateRef, nextText: string | TemplateRef}-
[onChange]change 事件触发的回调函数EventEmitter<number>-