Reputation: 1470
I am new to angular and am trying to load table data from controller.Data is coming but its not displaying in table.What went wrong here?
<script>
var app=angular
.module("intranet_App", [])
.controller('myCtrl', function ($scope, $http) {
$http.post("/Admin/getRolesList")
.then(function (response) {
console.log(response)
$scope.List= response.data;
console.log(List)
});
})
</script>
Here /Admin/getRolesList
is my controller name and path.
html:
<tbody >
<tr ng-repeat="x in List">
<td>{{List.Id}}</td>
<td>{{List.name}}</td>
</tr>
</tbody>
Upvotes: 0
Views: 506
Reputation: 488
//use track by for performance optimization..
<tbody>
<tr ng-repeat="x in List track by $index">
<td>{{x.Id}}</td>
<td>{{x.name}}</td>
</tr>
</tbody>
Upvotes: 1
Reputation: 38683
You have getting the values from like Array.value
, it should like Array[0].value
. So Use x.Id
instead of List.Id
,
<tbody>
<tr ng-repeat="x in List">
<td>{{x.Id}}</td>
<td>{{x.name}}</td>
</tr>
</tbody>
Upvotes: 1