import {Component, Input, Output, EventEmitter} from '@angular/core';
//Usage Example
@Component({
selector: 'paging-no-load',
template: `
`
})
export class pagingFormatterNoLoad {
@Input() public currentPage: number = 1;
// @Input() public navigateTo: string;
@Input() public term: string='';
@Input() public size: number=10;
@Input() public totalResults: number = 10;
// @Input() public params;
@Output() pageChange = new EventEmitter();
constructor () {
}
ngOnInit() {
console.info("In paging -- CurrentPage:"+this.currentPage+" "+"total Pages = "+this.getTotalPages() +" Results num:"+this.totalResults);
}
getTotalPages(){
var i= this.totalResults/this.size;
var integerI=parseInt(''+i);
return parseInt(''+((i==integerI)?i:i+1));
}
onPrev(){
this.currentPage=this.currentPage-1;
this.pageChange.emit({
value: this.currentPage
});
}
onNext(){
this.currentPage=this.currentPage+1;
this.pageChange.emit({
value: this.currentPage
});
}
onPage(pageNum: number){
this.currentPage=pageNum;
this.pageChange.emit({
value: this.currentPage
});
}
}