import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'pagination', templateUrl: './pagination.component.html', styleUrls: ['./pagination.component.css'] }) export class PaginationComponent implements OnInit { @Input() count: number =10; @Input() current: number = 1; @Input() range: number = 3; pages(): number[] { let array: number[] = []; let start = this.current - this.range; let end = this.current + this.range; if (start < 1) start = 1; if (end > this.count) end = this.count for (let i = start; i <= end; i++) array.push(i); return array; } first() { this.current = 1; } prev() { if (this.current > 1) this.current--; } goto(page: number) { this.current = page; } next() { if (this.current < this.count) this.current++; } last() { this.current = this.count; } ngOnInit(): void { } }