I have this in my factory
productsFactory.getOneProduct = function(){
$http({
method: 'GET',
url: '/api/products/' + $stateParams.productID
}).
success(function(data, status, headers, config){
console.log(data);
return data;
}).
error(function(data, status, headers, config){
});
}
This is my controller:
$scope.selectedProduct = ProductsFactory.getOneProduct();
console.log(data) outputs the data i want. But I get 'undefined' when I call it from controller. Guess it got something to do with returning from anonymous functions? Am I doing it wrong?