I have a controller defined as follows with the method getEmployeeDetails:
var app = angular.module('app');
app.controller('AppController',[ '$scope', '$http', function($scope, $http) {
$scope.result = [];
$scope.getEmployeeDetails = function() {
var response = $http.get('http://localhost:8080/empMgt/employee/all');
response.success(function(data, status, headers, config) {
$scope.result.push(data);
});
response.error(function(data, status, headers, config) {
alert( "Exception details: " + JSON.stringify({data: data}));
});
};
$scope.getEmployeeDetails();
}]);
This method gets a result object in return that has a list of employees in it. I am trying to show that list in a table in my html.
The html is as follows:
<body ng-controller="AppController" style="display:none">
{{result}}
<table>
<tr>
<th>EmployeeId</th>
<th>ProjectId</th>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>
<tr ng-repeat="employee in result.listOfEntities">
<td>{{employee.employeeId}}</td>
<td>{{employee.projectId}}</td>
<td>{{employee.employeeName}}</td>
<td>{{employee.employeeAddress}}</td>
</tr>
</table>
</body>
The object comes fine in the html as i printed the same. The list is not getting iterated in the table row.
The returned data looks like this:
{
"result": true,
"resultCode": "SUCCESS",
"listOfEntities": [{
"employeeId": "1",
"projectId": "1",
"employeeName": "asdfg",
"employeeAddress": "asdfg",
"project": null
}]
}
Help would be appreciated.
datavariable contains ? Are you sure thatlistOfEntitiesit's indataobject ?result?