I am looking to sort students by their class and then display them in an HTML
format.
Check out the code snippet here: http://plnkr.co/edit/GG9EYmPlIyD4ZM0ehaq6?p=preview
.html code:
<div ng-controller="ClassController">
<table>
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="student in students">
<td>{{ student.name }}</td>
</tr>
</tbody>
</table>
</div>
.js code:
var app;
app = angular.module('App', []);
app.controller('ClassController', [
'$scope', '$http', function($scope, $http) {
$scope.students = [];
return $http.get('data.json').then(function(result) {
return angular.forEach(result.data, function(item) {
return $scope.students.push(item);
});
});
}
]);
You can locate the .json
file on this link.