My JSON file is named brands.json:
{
"brands": {
"Honda": [
"Accord",
"Civic"
],
"Porsche": [
"Cayenne",
"Cayman"
]
}
}
I am attempting to loop through this list, display the brand names (e.g. Honda and Porsche), and render them using HTML lists.
<li ng-repeat="brand in items">{{brand}}</li>
Javascript:
$scope.items= [];
$http.get('brands.json').then(function(response) {
$scope.items =response.data.brands;
});
The code functions correctly but it currently shows the arrays within the brand names. For example, instead of displaying Honda, it displays ["Accord", "Civic"]. I want it to show only the brand names.
<li>Honda</li>
<li>Porsche</li>