I successfully converted 3 JSON files into an HTML page using AngularJS. Here is the code I used:
Factory code
app.factory('myapp', ['$http', function($http) {
function getLists() {
var tab = ['url1', 'url2', 'url3'];
var list = [];
for(i = 0; i < tab.length; i++) {
$http.get(tab[i])
.then(function(res) {
list.push(res.data);
});
}
return list;
}
return {
getLists: getLists
};
]);
I aim to organize and display the data from the different files based on gender (male/female) where it depends on the 'nm' field. The names of females should appear before the names of males, with each person's data from the first URL appearing in the first line, the second URL in the second line, and so on.
Html code:
<tr ng-repeat="d in list">
<td>{{d.nm}}</td>
<td>{{d.cty}}</td>
<td>{{d.hse}}</td>
<td>{{d.yrs}}</td>
</tr>
I am considering implementing a conditional test in the controller to segregate between female and male names. However, I am unsure about the exact approach. Any suggestions on how to proceed?