I think the title pretty sums up what I want to achieve. I looked in different SO threads regarding the issue, some uses $q while others do not. So I tried to pull something simple:
.factory('db',['$http',function($http){
return{
get:function(){
$http.get('https://randomuser.me/api/');
}
}
}])
.controller('PanelCtrl', [
'$scope',
'db',
function($scope, db){
db.get().then(function(response){
$scope.player=response.data;
});
Using Console.log I found that the data is fetched if I use the entire call inside the controller/factory. but here I'm getting undefined result in the $scope no matter what I do. The best outcome for me is to return the responsed data from factory to the $scope so all the $http call will be included inside my factory.