app.controller("HomeController", function ($scope, myService)
{ $scope.divStudent = false; GetAllStudent(); //To Get
All Records function GetAllStudent() { var getData = myService.getStudents(); getData.then(function (stud) { $scope.Students = stud.data; }, function () { $('#alertcontent').html('Error in getting
record'); $('#alertmodal').modal("show"); }); }
Service.js:
app.service("myService", function ($http) { //get All Student this.getStudents = function () { debugger; return $http.get("Home/GetAll"); }; //get StudentBy Id this.getStudent = function (StudentID) { var response = $http({ method: "post", url: "Home/getStudentByNo", params: { id: JSON.stringify(StudentID) } }); return response; }
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Service.js:
Home Controller:(ASP.NET 'HomeController')
Index.cshtml
Output: