I have a function where I obtain parameters from an API via $ http.post, the parameters that return are saved and printed inside the same request, however when I use them out the variable appears empty.
$scope.gama = {};
factoryGamas.buscarGama_x_nombre( objCons.gama ).then(function(reponse){
$scope.gama = reponse.data.fields;
});
If I do a console.log ($ scope.gama) the result is empty, or in this case {}
But when doing a console.log inside the function if I return the values.
factoryGamas.buscarGama_x_nombre( objCons.gama ).then(function(reponse){
$scope.gama = reponse.data.fields;
console.log( $scope.gama );
});
How could I use the variable outside the function if I am already using it within the $ scope?
Thanks!