gpt4 book ai didi

c# - Angular7 - 从 API 调用中获取响应

转载 作者:太空宇宙 更新时间:2023-11-03 19:38:42 25 4
gpt4 key购买 nike

我是 Angular 7 的新手,正在尝试了解 Http Client 的工作原理。来自 Angular 应用程序的 API 调用已完成,但我得到如下响应

enter image description here

我的 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() { }}

我只是调用 html 中的响应,如 Reporting filter works!
{{ShipmentList}}
。我不确定我在这里错过了什么。感谢任何帮助我正在学习 Angular 新手

最佳答案

因为你的数据是数组格式所以你应该像这样遍历你的数据

  <li *ngFor="let shipment of ShipmentList">
{{ shipment.customer_shipto_name }}
</li>

关于c# - Angular7 - 从 API 调用中获取响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57518765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com