File

src/app/shared/components/list/list-pagination.component.ts

Description

List Pagination Display the pagination and the pager

Metadata

selector app-list-pagination

Index

Methods
Inputs
Outputs

Inputs

item

Default value: item

items

Default value: items

page

Type: Page<any>

params

Type: any

Outputs

changed $event type: EventEmitter

Methods

changePage
changePage(page: number)
Parameters :
Name Type Optional Description
page number
Returns : void
changeSize
changeSize(size: number)
Parameters :
Name Type Optional Description
size number
Returns : void
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Page } from '../../model/page';

/**
 * List Pagination
 * Display the pagination and the pager
 */
@Component({
  selector: 'app-list-pagination',
  template: `<div class="list-pagination" *ngIf="page && params && page.totalElements > 0">
    <div class="list-pagination-wrap">
      <div id="pagination" class="app-pagination"
           *ngIf="page.totalPages > 1 && page.items.length > 0">
        <pagination-controls (pageChange)="changePage($event)"></pagination-controls>
      </div>
      <app-pager [item]="item" [items]="items" [page]="params.page" [total]="page.totalElements" [size]="params.size"
                 (sizeChange)="changeSize($event)">
      </app-pager>
    </div>
  </div>`
})
export class ListPaginationComponent {

  @Input() page: Page<any>;

  @Input() params: any;

  @Output() changed = new EventEmitter();

  @Input() item = 'item';

  @Input() items = 'items';

  changePage(page: number) {
    const obj = Object.assign({}, this.params);
    obj.page = page - 1;
    this.changed.emit(obj);
  }

  changeSize(size: number) {
    const obj = Object.assign({}, this.params);
    obj.size = size;
    this.changed.emit(obj);
  }

}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""