I'm getting an error when I try to retrieve data from a SQL Server database and there is more than 1 table with a foreign key.
Controller:
private DbContext db = new DbContext();
public JsonResult GetAll()
{
var result = db.Books.ToList();
return Json(result, JsonRequestBehavior.AllowGet);
}
Service.js:
var Service = {};
Service.getAll = function () {
return $http.get('BooksModels/GetAll');
};
Controller.js:
getAll();
function getAll() {
ToshokanService.getAll()
.success(function (an) {
$scope.books = an;
console.log($scope.books);
})
.error(function (error) {
$scope.status = 'Error' + error.message;
console.log($scope.status);
});
}
Error: "Errorundefined"
This works when I only have one table in database.
Is it a good idea to retrieve data from a database using AngularJS in ASP.NET MVC?
result
. – Arthur S. May 31 '16 at 8:27