<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.
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);
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments