Reputation:
<body ng-app="myAPP">
<div ng-controller="employeeCtrl">
<table style="border:1px solid gray">
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
<th>Employee Salary</th>
</tr>
<tr ng-repeat="emp in employees">
<td>
{{emp.EmployeeName}}
</td>
<td>
{{emp.EmployeeAddress}}
</td>
<td>
{{emp.EmployeeSalary}}
</td>
</tr>
</table>
</div>
var myAPP = angular.module('myAPP', []);
myAPP.controller('employeeCtrl', function ($scope, $http) {
$scope.employees = "";
$http({
method: 'GET',
url: '/Employee/GetEmployee'
}).then(function (result) {
$scope.employees = result;
}, function (result) {
console.log(result);
});
});
using angular 1.6.6 version data binding is not working though it returns results from http get method.
Upvotes: 0
Views: 63
Reputation: 691625
You're trying to iterate through a string. It should be
$scope.employees = [];
or
$scope.employees = null;
but not an empty string.
And later employees
becomes an HTTP response. Once again something that you can't iterate on. If the body of the response is indeed an array, then it should be
$scope.employees = result.data;
Upvotes: 0
Reputation: 222522
You need to access the data property of the response, change your controller method as follows, and $scope.employees
is an array
not a string
,
var myAPP = angular.module('myAPP', []);
myAPP.controller('employeeCtrl', function ($scope, $http) {
$scope.employees = [];
$http({
method: 'GET',
url: '/Employee/GetEmployee'
}).then(function (result) {
$scope.employees = result.data;
}, function (result) {
console.log(result);
});
});
Upvotes: 1