我有下面的代码I,但是数据没有显示在控制台日志中,请帮助我,我在角度上是新的。以及如何在HTML中显示数据
this.$http.get(properties.client+'/123')
.then(response => {
$scope.clientdata= response.data;
console.log($scope.clientdata.address);
});地址数组不显示在控制台日志中,我不知道为什么下面的响应
[{ "_id": "123",
"__v": 1,
"history": [],
"address": {
"street_address": "adsf",
"state": "adsf",
"zip_code": "adsf",
"phone_number": "asdf",
"country": "ads",
"city": "asdf",
"site_name": "adsf",
"_id": "123123",
"geolocation": {
"coordinates": [],
"type": "Point"
},
"location": {
"latitude": null,
"longitude": null
},
"id": "5835baaa71a30ca8319b6e36"
},
"current_status": "Assigned",
"time": 0
}]发布于 2016-12-01 11:47:21
您的客户端数据是一个数组,如文章所示,请尝试
console.log($scope.clientdata[0].address); {{clientdata[0].address}}发布于 2016-12-01 12:42:19
从JSON数据的结构来看,clientdata是一个对象数组,而就当前而言,数组中只有一个对象。因此,为了访问对象的address属性,您必须以这种方式访问它。
$scope.clientdata.address
以及在HTML中
{{clientdata.address._id}
和其他类似方式的address对象属性。
https://stackoverflow.com/questions/40909856
复制相似问题