title: How to get data from db using angularjs and entity framework in mvc
body: <p>I am newbie in learning AngularJS. Can anyone help me to understand how to get data from database using angularjs and entity-framework in mvc5.</p>
  
  <p>Let's say we have data table named:<br/> <code>tbl_student {rollno, name}</code><br/> and we want all the students data from the database. So what should be the most understandable way for new learners. </p>
  
  <p>Angular-Code</p>
  
  <pre><code>var myApp = angular.module("MyModule", []);
  myApp.controller("DBcontroller", function ($scope, $http) {
  $http.get("AngularController/AllStudents")
      .then(function (response) {
          $scope.students = response.data
      })
  })
  </code></pre>
  
  <p>Html-code in file named "Test.cshtml"</p>
  
  <pre><code>&lt;body  ng-app="MyModule"&gt;
  &lt;table ng-controller="DBcontroller"&gt;
       &lt;thead&gt;
            &lt;tr&gt;
               &lt;th&gt;Name&lt;/th&gt;
               &lt;th&gt;City&lt;/th&gt;
               &lt;th&gt;Institute&lt;/th&gt;
             &lt;/tr&gt;
       &lt;/thead&gt;
             &lt;tr ng-repeat="student in students"&gt;
               &lt;td&gt;{{ student.Name }}&lt;/td&gt;
               &lt;td&gt;{{ student.City }}&lt;/td&gt;
               &lt;td&gt;{{ student.Institute }}&lt;/td&gt;
            &lt;/tr&gt;
   &lt;/table&gt;
   &lt;/body&gt;
  </code></pre>
  
  <p>In MVC Controller</p>
  
  <pre><code>public class AngularController : Controller
  {
      // GET: Angular
      public ActionResult Test()
      {
          return View();
      }
  
      public JsonResult AllStudents()
      {
          using (EducationContext context = new EducationContext())
          {
              var students = context.tbl_Student.ToList();
              return Json(students, JsonRequestBehavior.AllowGet);
          }
      }
  }
  </code></pre>