我尝试在angularjs的html <div>
中显示我的数据。
当我这样做时:
<pre>
{{otherResponse.confirmation | json}}
</pre>
我可以在<pre>
中看到我的所有JSON数据,但我无法在简单的HTML <div>
中显示它们,我也不明白为什么。我使用两个不同的控制器,这些数据由于服务而共享。有什么帮助吗?
Bellow是我的JSON对象
的快速发布功能 app.post("/confirmation",function(req,res)
{
var departure=req.body.departure;
var destination=req.body.destination;
var timeDestination=req.body.timeDestination;
var timeDeparture=req.body.timeDeparture;
var price=req.body.price;
var firstName=req.body.firstName;
var lastName=req.body.lastName;
otherResponse = {
"confirmation": [{
"departure": departure,
"destination": destination,
"timeDeparture": timeDeparture,
"timeDestination": timeDestination,
"firstName": firstName,
"lastName": lastName,
"price": price
}]
};
res.json(otherResponse);
});
答案 0 :(得分:0)
试试这个,
<pre>
{{otherResponse.confirmation[0] | json}}
</pre>
答案 1 :(得分:0)
找到答案
<ul ng-repeat="x in otherResponse.confirmation">
<li>{{ x.departure }}</li>
</ul>