我试图让应用程序需要显示来自db的数据。但是从asp.net控制器发送数据到角度http.get服务时我遇到了问题。我有无法加载资源:服务器响应状态为500(内部服务器错误) 我的控制器:
public JsonResult JsonShowAll() {
var jsondata = db1.People.ToList<People>();
return Json(jsondata, JsonRequestBehavior.AllowGet);
}
我的js文件:
var userApp = angular.module("UserApp", []);
userApp.controller("UserController", function ($scope, $http) {
$http.get('/Home/JsonShowAll/').
success(function (data) {
$scope.people = data;
}).error(function (data, status, headers, config) {
console.log("response code: " + status);
})
})
并查看:
<div ng-app="UserApp" ng-controller="UserController">
{{people.FName}}
</div>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/UserJS.js"></script>