import {Component, Input} from "@angular/core";
@Component({
selector: 'results-and-pages',
template: `
0" [ngClass]="customClasses">
{{totalResults | number}}
{{type}}, page
{{currentPage}}
of
{{getTotalPages() | number}}
0" [ngClass]="customClasses">
{{totalResults | number}}
{{type}}
for
{{searchTerm}}
`
})
export class ResultsAndPagesNumComponent {
@Input() type: string;
@Input() page: number = 1;
@Input() pageSize: number = 10;
@Input() totalResults: number = 0;
@Input() customClasses: string = "";
@Input() hasSearch: boolean = false;
@Input() searchTerm: string;
constructor() {}
get currentPage() {
if(this.page > this.getTotalPages()) {
return this.getTotalPages();
} else {
return this.page;
}
}
getTotalPages(){
let total: number;
let i= this.totalResults/this.pageSize;
let integerI=parseInt(''+i);
total = parseInt(''+((i==integerI)?i:i+1));
return total;
}
}