i have the code at StudentController:
private StudentContext _context= new StudentContext(); [Route("api/student/GetStudents")] public IEnumerable<Student> GetStudents() { return _context.Students; }
it would return all the students.
at view i have the code that take this returned function
function customersController($scope, $http) {$http.get("/api/student/getStudents") .success(function (response) { $scope.students = response; });
and angular class that iterate over the list:
<table class="table table-striped"><thead><tr><td><b>ID</b></td><td><b>Nome</b></td></thead><tbody><tr ng-repeat="student in students" class="ng-scope"><td>{{ student.Id }}</td><td>{{ student.Name }}</td><td><button class="btn btn-primary" ng-click="selecionar(student)"><span class="glyphicon glyphicon-pencil"></span> Selecionar</button><button class="btn btn-primary" ng-click="deletar(customer.Id)"><span class="glyphicon glyphicon-remove"></span> Deletar</button></td></tr></tbody></table>
When i run the view i receive a error instead data
here is the error:
ExceptionMessage: "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'." ExceptionType: "System.InvalidOperationException" InnerException: {Message: "An error has occurred.",…} Message: "An error has occurred." StackTrace: null