Trying to figure out how to iterate through an array using ngrepeat.
If I have an array of data like this:
{
"People": [{
"name": "Andrew Amernante",
"rating": 3,
},
{
"name": "Frank Wang",
"rating": 5,
},
{
"name": "Chang Wang",
"rating": 5,
}
]
}
In my Controller, I have the following code snippets:
app.controller('mainController', function($scope, $http) {
$http.get('people.json').
then(function onSuccess(response) {
console.log(response);
$scope.peoples = response.data;
}).
catch(function onError(response) {
console.log(response);
});
});
I want to iterate through the array and display the three names in a list.
<ul class="nav">
<li ng-repeat="person in peoples track by $index">
<a href="#/">{{person.name}}</a>
</li>
</ul>
However, I'm having trouble getting the names to display. Any ideas on what might be going wrong?
For your information, I am using Angular version 1.6.5 here.
Plunkr with the full code provided.