My problem is that I make a request for $http
to recover some data that I need to use in my controller, the problem is that if I make a console.log
out with the variable assigned to the data it marks undefined
.
I wanted to know if there is any way to use the data from that $scope
without being within then
of $http
.
Example:
$http.get(config.root + 'index/trlang/'+lang).success(
function(data){ $rootScope.trlang = data['lang'];}
);
console.log($rootScope.trlang); // undefined
This is when executing the controller, in the view the data is shown correctly, but in the controller I can not use that data since the requests are loaded in the last instance.