我想從工廠獲取http請求數據,在父控制器中處理數據並將其傳回工廠供我的子控制器訪問。如何在我的情況下將數據傳遞給另一個控制器?
我有類似
父控制器
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;
})
兒童控制器
//I want to get the productDetail through parent' $scope.productDetail.
//but not sure how to get 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)
}
基本上我不知道如何通過productD etail到我的孩子控制器。感謝幫助。