I'm currently working on pulling HTTP request data from a factory, processing it in a parent controller, and then passing it back to the factory for my child controller to access.
This is what I have so far:
Parent Controller
myFactory.makeApi(id)
.then(function(data) {
//process data here...
//I want to pass productDetail back to my factory and let
//my child controller use it
$scope.productDetail = productDetail;
})
Child Controller
//I want to retrieve the productDetail using the parent's $scope.productDetail.
//but I'm not sure how to do it.
myFactory.getProductDetail ???
myFactory
service.makeApi = function(id) {
return getProduct(id)
.then(function(httpObj) {
return httpObj.data;
})
}
var getProduct = function(id) {
return $http.post('/api/product/getProduct/' + id)
}
Essentially, I'm struggling with passing the productDetail to my child controller. Any help would be greatly appreciated. Thank you.