我是新的角7,并试图学习如何Http客户端工作。来自角应用程序的APi调用已经发出,但我得到的响应如下

我的service.ts如下所示
export class ReportingFilterService {
shipmentByProjectResult: any[];
constructor(service: DataService) {
}
getShipmentByPrj(): ShipmentByProject[] {
return this.shipmentByProjectResult;
}
}其中ShipmentByProject是一个模型类
export class ShipmentByProject {
Id: string;
project_number: string;
related_project_number: string;
Reporting_Project: string;
customer_shipto_name: string;
sales_order_TJL_ship_date: Date |string|null;
deliverydate: Date |string|null;
delivery_mode : string;
customer_purchase_order: string;
total_qty: number|null;
}和组件
export class ReportingFilterComponent implements OnInit {
ShipmentList: ShipmentByProject[];
entityUrl = 'ShipmentDetail/GetByReportingProject?repPrj=000634';
constructor(service: DataService) {
service.get<ShipmentByProject[]>(this.entityUrl).subscribe(x =>
{this.ShipmentList = x });
}
ngOnInit() { }}我只是像调用Reporting filter works! {{ShipmentList}}一样调用html中的响应。我不知道我在这里错过了什么。任何帮助我都很感激,因为我正在学习和新的角度。
发布于 2019-08-16 04:26:23
因为您的数据是数组格式的,所以您应该像下面这样循环遍历数据
<li *ngFor="let shipment of ShipmentList">
{{ shipment.customer_shipto_name }}
</li>发布于 2019-08-16 04:49:12
您的数据变量'ShipmentList‘被初始化为数组。因此,您应该迭代数组,以获得每个配送数据,如下所示:
<div *ngFor="let shipment of ShipmentList">{{shipment.objectName}} //objectName can be Id,customer_purchase_order etc
</div>https://stackoverflow.com/questions/57518765
复制相似问题