angular2-bootstrap-pagination is angular2 directive.
The sources for this package are in (https://github.com/rajan-g/angular2-bootstrap-pagination.git) repo. Please file issues and pull requests against that repo.
npm install angular2-bootstrap-pagination
/*
* @author RAJAN G
*/
//module file
import {PaginationDirective} from '../directives/pagination.directive';
//include pagination directive
@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [AppComponent, PaginationDirective],
bootstrap: [ AppComponent ]
})
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: `<ng-pagination [totalItems]="totalItems" [(ngModel)]="currentPage" [maxSize]="maxSize" [boundaryLinks]="true" (pageChanged)="pageChanged($event)"
previous-text="‹" next-text="›" first-text="First" last-text="Last">`,
})
export class AppComponent {
public currentPage:number = 1;
public totalItems:number = 200; // total numbar of page not items
public maxSize:number = 10; // max page size
constructor() {
}
public setPage(pageNo:number):void {
this.currentPage = pageNo;
};
public pageChanged(event:any):void {
//this method will trigger every page click
console.log('Number items per page: ' + event.itemsPerPage);
};
}
- Download this module
- Run following command
npm install npm start