Commit 70bbdb4d by Nakarin Luankla

แก้ค้นหา แล้วpage ไม่กลับมาหน้าหนึ่ง

parent 314cb648
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Component, Input, Output, EventEmitter, SimpleChanges, ChangeDetectorRef } from '@angular/core';
@Component({
selector: 'app-pagination',
......@@ -8,12 +8,17 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
export class PaginationComponent {
@Input() totalItems = 0;
@Input() pageSize = 10;
currentPage = 1;
@Output() pageChange = new EventEmitter<number>();
@Output() pageSizeChange = new EventEmitter<number>();
currentPage = 1;
constructor(private cdr: ChangeDetectorRef) { }
pageSizes = [10, 20, 50, 100];
ngOnChanges() {
this.changePage(1)
this.cdr.detectChanges();
}
get totalPages(): number {
return Math.ceil(this.totalItems / this.pageSize);
}
......@@ -26,7 +31,6 @@ export class PaginationComponent {
if (total <= 7) {
return Array.from({ length: total }, (_, i) => i + 1);
}
pages.push(1);
if (current > 3) pages.push('...');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment