This commit is contained in:
geek 2018-06-11 12:27:25 +09:00
parent 7a1e1bf3b6
commit c844548d68
2 changed files with 36 additions and 23 deletions

View File

@ -50,32 +50,33 @@ export class ListComponent implements OnInit, OnChanges {
}
ngOnInit() {
this.getTargetList();
}
ngOnChanges(changes: SimpleChanges): void {
console.log(changes);
if (changes['pageIdx'] && this.paginator) {
console.log(this.pageIdx);
this.getTargetList();
this.paginator.changePage(this.pageIdx);
}
}
private getTargetList() {
// console.log('----------------------------------------------------------------');
// console.log(this.pageIdx);
// console.log('----------------------------------------------------------------');
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null || isNaN(this.pageIdx)) {
this.pageIdx = 0;
}
const pageParams: PageParams = {
pageNo: 0,
pageNo: this.pageIdx,
countPerPage: 2,
sortCol: 'id',
sortDirection: 'descending',
};
this.getTargetList(pageParams);
}
ngOnChanges(changes: SimpleChanges): void {
if (changes['pageIdx'] && this.paginator) {
const pageParams: PageParams = {
pageNo: this.pageIdx,
countPerPage: 2,
sortCol: 'id',
sortDirection: 'descending',
};
console.log(this.pageIdx);
this.paginator.changePage(this.pageIdx);
this.getTargetList(pageParams);
}
}
private getTargetList(pageParams: PageParams) {
this.targetService.readAllByProbeID(this.probeID, pageParams)
.pipe(
tap(() => {

View File

@ -12,15 +12,27 @@ export class TargetListPageComponent implements OnInit {
constructor(
private router: Router,
private route: ActivatedRoute
private activatedRoute: ActivatedRoute
) { }
ngOnInit() {
this.activatedRoute.queryParams.subscribe(queryParams => {
this.pageIdx = Number(queryParams['page']);
if (this.pageIdx <= 0 || this.pageIdx === undefined || this.pageIdx === null) {
this.pageIdx = 0;
}
// console.log('*****************************************************');
// console.log(this.pageIdx);
// console.log('*****************************************************');
});
// this.pageIdx = this.activatedRoute.snapshot.queryParams['page'] || 1;
}
onPageChange(pageNo: number) {
this.pageIdx = pageNo + 1;
this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: pageNo + 1 } });
// console.log('**********************pageNo*******************************');
// console.log(pageNo);
// console.log('**********************pageNo*******************************');
this.router.navigate(['/probe', this.probeID, 'target'], { queryParams: { page: pageNo } });
}
}