Extracting information from 2 different JSON files:
1st JSON file 'names.json':
[
{
"name": "AAAAAA",
"down": "False"
},
{
"name": "BBBBBB",
"down": "45%"
},
{
"name": "CCCCC",
"down": "12%"
}
]
Second JSON file 'data.json'
[
{
"data": "25-12-2014"
}
]
Javascript:
app.service('service', function($http){
this.getNames = function () {
var data = $http.get('data,json', { cache: false });
var names = $http.get('names.json', { cache: false });
return names;
return data;
};
});
app.controller('FirstCtrl', function($scope, service) {
var promise = service.getNames();
promise.then(function (data) {
$scope.datas = data.data;
console.log($scope.datas);
});
})
HTML
<div ng-controller="FirstCtrl">
<table>
<tbody>
<tr ng-repeat="name in datas">
<td>{{name.name}}</td>
<td>{{name.data}}</td>
</tr>
</tbody>
</table>
</div>
Despite accessing both JSON files in the JavaScript code, I am only able to display data from 'names.json' in my console.log and table. How can I also display data from 'data.json'? Thank you.