我有这个代码,它调用REST API:
是名为
的组件中的方法load(loadParams: IDatatableLoadEvent): void {
this.loading = true;
this.productService.loalProducts(loadParams.sortBy, loadParams.currentPage, loadParams.pageSize, loadParams.searchTerm, loadParams.sortOrder.toLowerCase())
.subscribe((res: HttpResponse<IProduct[]>) => {
this.filteredData = res.body;
// we have to set x-pagination to COSR rules on API server
const xPagination = res.headers.get('x-pagination');
this.filteredTotal = JSON.parse(xPagination).totalCount;
this.loading = false;
// Hack - because we are setting loading and until data are loaded
// we have to stop changeDetection and tell angular when to detect changes
// - this happens only when we are changing pagesize
this.cdr.detectChanges();
}, error => {
this.loading = false;
console.log(error);
});
}
问题是,当我收到错误时,错误处理事件被触发,但此上下文不是该组件,但是 SafeSubscriber