This commit is contained in:
geek 2018-06-11 22:02:27 +09:00
parent 0bffcfb03b
commit a1b513f766
3 changed files with 17 additions and 13 deletions

View File

@ -30,7 +30,7 @@
</tr>
</ng-template>
</p-table>
<p-paginator #paginator [rows]="targetPage.size" [totalRecords]="targetPage.totalElements"
<p-paginator #paginator [rows]="targetPage.size" [totalRecords]="targetPage.totalElements" [first]="pageIdx"
(onPageChange)="onPaginate($event)"></p-paginator>
</ng-template>

View File

@ -54,28 +54,28 @@ export class ListComponent implements OnInit, OnChanges {
}
ngOnInit() {
this.location.onPopState(() => {
// alert(window.location);
this.paginator.changePage(this.pageIdx);
});
this.getTargetList();
}
ngOnChanges(changes: SimpleChanges): void {
// console.log(changes);
if (changes['pageIdx'] && this.paginator) {
if (changes['pageIdx']) {
// console.log(this.pageIdx);
this.getTargetList();
this.paginator.changePage(this.pageIdx);
// const p: number = this.pageIdx - 1;
// this.paginator.changePage(this.pageIdx);
}
}
private getTargetList() {
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 0;
this.pageIdx = 1;
}
const p: number = this.pageIdx - 1;
const pageParams: PageParams = {
pageNo: this.pageIdx,
pageNo: p,
countPerPage: 2,
sortCol: 'id',
sortDirection: 'descending',
@ -111,6 +111,6 @@ export class ListComponent implements OnInit, OnChanges {
onPaginate(e) {
// e.changePage();
this.pageChange.emit(e.page);
this.pageChange.emit(Number(e.page));
}
}

View File

@ -22,14 +22,18 @@ export class TargetListPageComponent implements OnInit {
this.pageIdx = Number(queryParams['page']);
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 0;
this.pageIdx = 1;
}
});
}
onPageChange(pageNo: number) {
this.pageIdx = pageNo;
this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: pageNo } });
// console.log(pageNo);
// if (pageNo + 1 === this.pageIdx) {
// return;
// }
this.pageIdx = pageNo + 1;
this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: this.pageIdx } });
}
onTargetSelect(target: Target) {