Currently, I am in the process of creating a ticket admin table. However, I am facing some challenges with exporting a variable outside of an ajax function.
Here is my code:
app.controller('bodyController',function($scope,$http,$sce){
$scope.ticketList = [];
$http.get("tickets.php")
.then(function(response) {
$scope.ticketModify = response.data;
console.log($scope.ticketModify); //this one return the correct data.
return $scope.ticketModify;
});
console.log($scope.ticketModify); //this return undefine
I encountered the same issue when using factory to attempt to store the response.data
in a variable.