如何使用angular2在分页中使用左箭头和右箭头替换上一个和下一个箭头

时间:2017-11-08 11:55:42

标签: html css angular pagination

我有一个分页,我在前一个和下一个。任何人都可以帮助我用左右箭头替换它

HTML:

<pagination-controls (pageChange)="page = $event" id="1" maxSize="10" directionLinks="true" autoHide="true" class="page">
      </pagination-controls>

CSS:

.left {
  display: inline-block;
  width: 4em;
  height: 4em;
  margin-right: 1.5em;
}

.left:after {
  content: '';
    display: inline-block;
  margin-top: 1.05em;
  margin-left: 0.6em;
  width: 1.4em;
  height: 1.4em;
  border-top: 0.5em solid #333;
  border-right: 0.5em solid #333;
  -moz-transform: rotate(-135deg);
  -webkit-transform: rotate(-135deg);
  transform: rotate(-135deg);
}

.right {
  display: inline-block;
  width: 4em;
  height: 4em;
  margin-left: 1.5em;
}

.right:after {
  content: '';
    display: inline-block;
  margin-top: 1.05em;
  margin-left: -0.6em;
  width: 1.4em;
  height: 1.4em;
  border-top: 0.5em solid #333;
  border-right: 0.5em solid #333;
  -moz-transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

这是右箭头和左箭头的CSS,我怎么用html写这个,我的意思是如何链接?

1 个答案:

答案 0 :(得分:2)

您使用的分页插件是完全可自定义

您甚至可以创建完全自定义的模板。

这是我创建的一个例子,

<强>组件,

export class AppComponent {
  collection = [];
  constructor() {
    for (let i = 1; i <= 100; i++) {
      this.collection.push(`item ${i}`);
    }
  }
   public config: PaginationInstance = {
        id: 'custom',
        itemsPerPage: 10,
        currentPage: 1,
        directionLinks: false
    };
}

自定义HTML,

<div class="container-fluid">
  <div class="row">
    <div class="medium-8 medium-offset-2 columns">
        <h2 class="subheader"></h2>
        <ul>
          <li *ngFor="let item of collection | paginate: config">{{ item }}</li>
        </ul>
    </div>
  </div>
  <div class="row">
    <pagination-template #p="paginationApi"
    [id]="config.id"
    (pageChange)="config.currentPage = $event">
    <div class="custom-pagination">
        <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>
    </pagination-template>
  </div>
</div>

Here is their official custom template document

A WORKING DEMO

<强> PS:

您甚至可以根据需要添加css代码并进行自定义