【发布时间】:2018-01-16 09:05:16
【问题描述】:
您好,我必须以模式显示数据。为此,我使用 Angular2 服务并使用 Web 服务从后端数据库显示。这样做时,我收到以下 2 个错误。
1) 加载资源失败:服务器响应状态为500() 2) 错误类型错误:您在预期流的位置提供了无效对象。您可以提供 Observable、Promise、Array 或 Iterable
下面是 Angular2 服务,后面是 Angular2 方法。请帮我解决这个问题。所有这些输出列表/数据数组。
Angular2 服务
产品服务
public GetProductInfo(prodId, depId, custId): Observable<any> {
let myParams = new URLSearchParams();
myParams.append('prodId', prodId);
myParams.append('depId', depId);
myParams.append('custId', custId);
let options = new RequestOptions({ params: myParams });
return this.commonService.get(this.GetProductEndpoint, options);
}
component.ts 中的 Angular2 方法
private loadGetProductInfo(prodId: any, depId: any, custId: any) {
this.productsService.GetProductInfo(prodId, depId, custId)
.subscribe((result) => {
if (result != null) {
this.GetProductInfo = result;
this.temp = [...result];
this.productsInfo = result;
}
});
}
【问题讨论】: