I'm trying to get the result of a JSON request into a table using angular ng-repeat, but nothing happens. Console shows no errors, breakpoint in .NET Controller doesn't get hit.
Code for App Controller:
var app = angular.module('angularTable', []);
app.controller('listdata', function ($scope, $http) {
$scope.contacts = [];
$http({ method: 'GET', url: '/Contacts/GetContacts/' }).success(function (response) {
$scope.contacts = response;
});
});
.NET Controller
[HttpGet]
public JsonResult GetContacts()
{
var data = db.Contacts.Include(x => x.Cities).Include(a => a.Groups);
return Json(data);
}
HTML:
<div ng-app ="angularTable">
<table class="table table-hover" ng-controller="listdata">
<thead>
<tr>
<th>Name</th>
<th>Phone</a></th>
<th>Group</th>
<th>City</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in contacts">
<td>{{item.name}}</td>
<td>{{item.area}} {{item.phone}}</td>
<td>{{item.group.description}}</td>
<td>{{item.city.name}}</td>
<td>
<a asp-route-id="{{item.id_Contact}}">Send Message | </a>
<a asp-route-id="{{item.id_Contact}}">Edit | </a>
<a asp-route-id="{{item.id_Contact}}" asp-action="Delete">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
Using this CDN for AngularJS:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>