this is the JSON document I'm trying to read data from:
{title": "some name here",
"details": {
"color": "red",
"location": "at home",
"shape": "square"
}}
I'm trying to read this data in my js file and then add this to html. Here's my code:
$http.get('/api/dataIuse')
.success(function(rdata) {
$scope.title = rdata['title'];
$scope.details = rdata['details'];
$scope.fullData = rdata;
console.log(rdata['title']);
})
.error(function(rdata) {
console.log('Error: ' + rdata);
});
How can I read inside of 'details' to get color, location and shape seperately??
This is my guess (it doesn't work):
$scope.details.color = rdata['details.color'];
$scope.details.location = rdata['details.location'];
$scope.details.shape = rdata['details.shape'];
What method of reading JSON should I use?
Thanks!