{{project.ProjectName}}
is not showing any data in my browser. I have data in the db, I have the needed script files ref'd in my _Layout, and ng-app="myApp"
in the body. Debugging the controller does return 1 row of data. Not sure what I am doing wrong. It should show 1 row with the ProjectName.
Controller:
public ActionResult Index()
{
return View();
}
public JsonResult GetAllProjects()
{
EEDBEntities db = new EEDBEntities();
var result = db.Projects.ToList();
return Json(result, JsonRequestBehavior.AllowGet);
}
App.js:
var myApp = angular.module('myApp', []);
myApp.controller('mainController', function($scope, $http) {
$http.get('/home/GetAllProjects')
.success(function(result) {
$scope.projects = result;
})
.error(function(data) {
console.log(data);
});
});
Index.cshtml:
<h3>
All Projects
</h3>
<div ng-controller="mainController">
<table class="table table-striped">
<tr ng-repeat="project in projects">
<td>{{project.ProjectName}}</td>
<td class="text-right">
<button class="btn-danger">X</button>
</td>
</tr>
</table>
</div>