0.0.2 • Published 6 years ago
angular2paginator-ts v0.0.2
Angular 2 Paginator
A pagination module for Angular 2 applications.
Installation
npm install angular2paginator-ts --saveDemo
Demo at stackblit.
Angular Version
This library is built to work with Angular 6+, and support ahead-of-time compilation. If you need to support an earlier or pre-release version of Angular for now, please see the changelog for advice on which version to use.
Usage
// app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { Angular2Paginator } from 'angular2paginator-ts';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
Angular2Paginator
],
declarations: [
AppComponent
],
bootstrap: [
AppComponent
]
})
export class MyAppModule {}// app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-component',
template: `
<angular2paginator
[length]="length"
[currentPage]="currentPage"
[pageSize]="pageSize"
[pageSizeOptions]="pageSizeOptions"
[maxPagesToShow]="maxSize"
[autoHide]="true"
[disabled]="searching"
(page)="onPageChange($event)">
</angular2paginator>
`
})
export class AppComponent {
length: number = 100;
currentPage: number = 1;
pageSize: number = 10;
pageSizeOptions: number[] = [ 10, 25, 50, 100 ];
maxSize: number = 4;
searching: boolean = false;
public onPageChange(event: any) {
console.log(event);
}
}API
lengthnumberTotal number of items.currentPagenumberCurrently selected page.pageSizenumberNumber of items per page. Default is25.pageSizeOptions[number[]] The set of provided page size options to display to the user.maxPagesToShownumberMaximum number of pages visible for selection. Default is5.autoHidebooleanHides the whole paginator if there is only one page. Default isfalse.disabledbooleanDisables the pagination controls. Default isfalse.circleButtonbooleanIf set totrue, the buttons will be displayed in the shape of circles. Default isfalse.pageevent handlerEvent emitted when the user changes the page or the number of items per page. The$eventargument will be an object with the following properties:length:numbercurrentPage:numberpreviousPage:numberpageSize:numberpageSizeOptionsLabelstringThe label displayed on the page size options. Default isItems per page.hidePageSizeOptionsLabelbooleanHides the label for the page size options. Default isfalse.previousPageLabelstringThe label displayed on the tooltip of the button on the "previous" page. Default isPrevious.nextPageLabelstringThe label displayed on the tooltip of the button on the "next" page. Default isNext.firstPageLabelstringThe label displayed on the tooltip of the button on the "first" page. Default isFirst.lastPageLabelstringThe label displayed on the tooltip of the button on the "last" page. Default isLast.disableTooltipbooleanDisables tooltips to show the labels on the control buttons. Default isfalse.
Test
npm run test