Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
您的服务不会返回productTableItem,而是服务器响应。创建两个模型:
productTableItem
export class ProductData { products?: ProductTableItem[] }
现在
export class ServerResponse<T> { timestamp: any; status: string; data: T; }
在您的服务中:
getProducts(): Observable<ServerResponse<ProductData>> { return this.http.get<ServerResponse<ProductData>>(this.productUrl) .pipe( tap(data => console.log('All', JSON.stringify(data))), catchError(this.handleError) ); }
在您的组件中:
this.productService.getProducts().subscribe({ next: (response : ServerResponse<ProductData>) => this.data = response?.data?.products, error: err => this.errorMessage = err });
Your service doesn't return ProductTableItem but the server response. Create two models:
ProductTableItem
and
Now in your service:
and in your component:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
您的服务不会返回
productTableItem
,而是服务器响应。创建两个模型:现在
在您的服务中:
在您的组件中:
Your service doesn't return
ProductTableItem
but the server response. Create two models:and
Now in your service:
and in your component: