这是我的mvc控制器并查看代码
[HttpGet]
public ActionResult getmanualList()
{
if (Session["loginId"] != null)
{
var json = db.Items;
return Json(json, JsonRequestBehavior.AllowGet);
}
else
return RedirectToAction("Login", "User");
}
这是我的查看代码
@model List<QuotationSystem.Models.Item>
@{
ViewBag.Title = "manualView";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div data-ng-app="App" data-ng-controller="CLTR">
<input type="button" onclick="BtnClick()" value="Click me"></input>
</div>
</body>
<script>
var app = angular.module("App", ['ui.bootstrap']);
app.controller("CLTR", function ($scope, $http) {
alert("ha");
function BtnClick() {
$http.get("/ViewPriceList/getmanualList")
.then(function (response) {
alert("agya");
console.log(response);
}, function () {
alert("Error!\nFailed To Load Data. Please Try Again.");
});
}
}
</script>