This is my controller:
ProductsFactory.getOneProduct().then(function(d){
$scope.selectedProduct = d.data;
console.log($scope.selectedProduct); //Working
});
console.log($scope.selectedProduct); //Undefined
I can access the data from within the function. But not from outside. This means I cant use the data in my GUI. How do I make access from outside?
Update Apperently it is working in the GUI. But you can not console anything outside.
$scope.selectedProductisundefined. After your async request executes and you update the$scopewith new data Angular will know it needs to update the view also. It's been discussed in great detail here: stackoverflow.com/questions/13033118/…