import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Paging } from '@creedinteractive/onguard-models'; @Component({ selector: 'onguard-paging', templateUrl: './paging.component.html', styleUrls: ['./paging.component.scss'] }) export class PagingComponent { @Input() model: Paging = new Paging(10); @Output() notify: EventEmitter = new EventEmitter(); public requestedPage: number; constructor() { } public goNext(): void { this.notify.emit(this.model.currentPage + 1); } public goPrev(): void { this.notify.emit(this.model.currentPage - 1); } public goToPage(): void { if (this.requestedPage < 1 || this.requestedPage > this.model.pageCount) { this.requestedPage = null; } else { this.notify.emit(this.requestedPage); } } public hasPrev(): boolean { return this.model.currentPage > 1; } public hasNext(): boolean { return this.model.currentPage < this.model.pageCount; } }