以下是我的API调用并在this.order.info
中获取响应this.http.get(this.order_info_url+'/'+this.order_id)
.subscribe(
response => {
this.order_info = response.json();
console.log(this.order_info[0]);
},
error => {
alert(error.text());
return error.text();
}
);
我的回应是
{
"table1": [
{
"store_name": "Your Store",
"store_url": "http://localhost:8080/upload/",
"date_added": "2016-11-18T07:51:53.000Z",
"payment_method": "Cash On Delivery",
"shipping_method": "Flat Shipping Rate",
"firstname": "q",
"lastname": "q",
"Customer_Group_Name": "Default",
"email": "q@g.com"
}
],
"table2": [
{
"Customer_Notified": "NO",
"date_added": "2016-11-18T07:51:54.000Z",
"comment": "",
"name": "Pending"
}
]
}
我如何从component.ts
获取模板中的table1.store_name答案 0 :(得分:1)
你应该得到这样的价值:
<p>{{ order_info?.table1[0].store_name }}</p>