Reputation: 1059
Here is my code,
$scope.output=abc(1,2);
function abc(mid, type) {
$http({
...
}
}).then(function (response) {
return response.data;
}, function (response) {
});
}
console.log($scope.output)
$scope.output
is
undefined
Function is executing but data is not assigning to $scope variable
Upvotes: 1
Views: 747
Reputation: 27222
Instead of using return
in async call
. You can directly assign the response.data into the $scope.output
variable.
abc(1,2);
function abc(mid, type) {
$http({
...
}
}).then(function (response) {
$scope.output = response.data;
}, function(error) {
});
}
Upvotes: 0
Reputation: 1322
abc(1,2);
function abc(mid, type) {
$http({
...
}
}).then(function (response) {
$scope.output = response.data;
}, function (response) {
});
}
console.log($scope.output)
In async operations, you cannot use return
Upvotes: 1