openaire-library/utils/resultsAndPagesNum.componen...

33 lines
848 B
TypeScript

import {Component, Input} from "@angular/core";
@Component({
selector: 'results-and-pages',
template: `
<h6 *ngIf="type && totalResults" [ngClass]="customClasses">
<span>{{totalResults | number}}</span>
<span class="uk-text-meta uk-text-capitalize"> {{type}}, page </span>
<span>{{page}}</span>
<span class="uk-text-meta"> of </span>
<span>{{getTotalPages() | number}}</span>
</h6>
`
})
export class ResultsAndPagesNumComponent {
@Input() type: string;
@Input() page: number = 1;
@Input() pageSize: number = 10;
@Input() totalResults: number;
@Input() customClasses: string = "";
constructor() {}
getTotalPages(){
let total: number;
let i= this.totalResults/this.pageSize;
let integerI=parseInt(''+i);
total = parseInt(''+((i==integerI)?i:i+1));
return total;
}
}