Current 'solution' with Angular Paginator service
I tried to use the paginator service now with some 'hacks' for setting the this.paginator.pageIndex= within the component..
File list.component.ts:
this.paginatorService.pageChange.subscribe((pageEventData) => {
if (pageEventData.fetchData) {
if (pageEventData.goToFistPage) {
// Should return to the first page
this.paginator.pageIndex = 0;
}
this.ledgerService.getAll(pageEventData.url, pageEventData.params)
.pipe(
map(resp => {
this.paginatorService.setError(false);
this.paginatorService.setPaginationData(resp.headers);
this.paginatorService.setLoading(false);
return resp.body;
}),
catchError((error) => {
this.paginatorService.setLoading(false);
this.paginatorService.setError(true);
console.error(error);
return observableOf([]);
})
).subscribe(data => this.dataSource.data = data);
} else {
// Only restore old page ID
this.paginator.pageIndex = pageEventData.pageIndex;
}
});
Please register or sign in to comment