我有下面的代码,但数据没有显示在控制台日志中,请帮助我,我是 Angular 新手..以及如何在 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
}]
最佳答案
您的 clientdata 是一个数组,请尝试
console.log($scope.clientdata[0].address);
HTML
{{clientdata[0].address}}
关于javascript - angularjs 响应数据不显示在控制台中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40909856/