I am trying to get a List of test customers from the server. I know that the Web API controller is receiving the data from the DB because I have unit/integration tests around it; however, when I try and pull the data to my angular controller I receive a 500 status code.
Angular Controller:
var surchargeIndex = angular.module('surchargeIndex', []);
surchargeIndex.controller('SurchargeIndexController', function ($scope, customerService) {
$scope.customers = { Key: "", Value: "" };
customerService.getTest($scope);
});
surchargeIndex.service('customerService', [
'$http', function($http) {
this.getTest = function ($scope) {
return $http({
method: "GET",
url: "api/Customer/GetTest",
})
.success(function (data) {
$scope.customers = data;
})
.error(function () {
$scope.error = "Failed to load customers!";
});
}
}
]);
Web Api:
[RoutePrefix("api/Customer")]
public class CustomerController : ApiController
{
private readonly ICustomerService _service;
public CustomerController(ICustomerService service)
{
_service = service;
}
[Route("GetTest"), HttpGet]
public IEnumerable<IJsonResult> GetTest()
{
return _service.GetTest();
}
}
What am I missing?