In your current function if you are assigning $scope.persons
to $http
which is a promise object as $http
returns a promise object.
So instead of assigning scope.persons
to $http you should assign $scope.persons
inside the success of $http
as mentioned below:
function TestController($scope, $http) {
$http({
url: 'http://samedomain.com/GetPersons',
method: "POST",
data: postData,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function (data, status, headers, config) {
$scope.persons = data; // assign $scope.persons here as promise is resolved here
}).error(function (data, status, headers, config) {
$scope.status = status;
});
}