import { Component, OnInit, Input, Output, EventEmitter, OnChanges } from '@angular/core';

@Component({
  selector: 'neu-paginator',
  templateUrl: './neu-paginator.component.html',
  styleUrls: ['./neu-paginator.component.css']
})
export class NeuPaginatorComponent implements OnInit {

  @Input("length") length:number; //total number of items that are being paginated
  @Input("pageSize") pageSize:number; //number of items to display on the page
  @Output() pageChange:EventEmitter<number> = new EventEmitter();
  @Input() page:number = 0;

  constructor() { }

  ngOnInit(): void {
    //check
    if(!this.length || !this.pageSize) throw new TypeError("length and pageSize are required.");
  }

  changePage(num:number) {
    this.page = num;
    this.pageChange.emit(this.page);
  }

}
