mvc控制器数据如何查看

时间:2019-06-10 10:10:05

标签: json model-view-controller get

这是我的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>

0 个答案:

没有答案