Commit 6af675ae by Nakarin Luankla

แก้ bug pagination

parent 70bbdb4d
......@@ -144,6 +144,6 @@ export class SubJobPositionIndicatorsComponent {
positionClass: 'toast-top-right',
})
}
}
\ No newline at end of file
......@@ -31,12 +31,12 @@
<!-- ตัวเลือกจำนวนรายการต่อหน้า -->
<li>
<select class="ti-form-select" [(ngModel)]="pageSize" (ngModelChange)="onPageSizeChange()">
<option *ngFor="let size of pageSizes" [value]="size">{{ size }}</option>
<option *ngFor="let size of pageSizes" [ngValue]="size">รายการต่อหน้า: {{ size }}</option>
</select>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{ (currentPage - 1) * pageSize + 1 }} to {{ getEndIndex() }} of {{ totalItems }} items</span>
<span >แสดง {{ (currentPage - 1) * pageSize + 1 }} ถึง {{ getEndIndex() }} จาก {{ totalItems }} รายการ</span>
</ul>
</nav>
......@@ -11,14 +11,13 @@ export class PaginationComponent {
currentPage = 1;
@Output() pageChange = new EventEmitter<number>();
@Output() pageSizeChange = new EventEmitter<number>();
constructor(private cdr: ChangeDetectorRef) { }
pageSizes = [10, 20, 50, 100];
ngOnChanges() {
this.changePage(1)
this.cdr.detectChanges();
}
constructor(private cdr: ChangeDetectorRef) { }
pageSizes: number[] = [10, 20, 50, 100];
ngOnChanges() {
this.changePage(1)
this.cdr.detectChanges();
}
get totalPages(): number {
return Math.ceil(this.totalItems / this.pageSize);
}
......@@ -33,7 +32,7 @@ ngOnChanges() {
}
pages.push(1);
if (current > 3) pages.push('...');
const middlePages = [current - 1, current, current + 1].filter(p => p > 1 && p < total);
pages.push(...middlePages);
......
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