AngularJS कारखाना और नियंत्रक - angularjs, angularjs-scope, angularjs-नियंत्रक, angularjs-factory

यहाँ थोड़ी समस्या है, मेरे पास एक नियंत्रक है जो कारखानों के साथ संवाद करता है, लेकिन मैं एक समारोह में कारखाना परिणाम कैसे पारित कर सकता हूं? कुछ मैंने कोशिश की:

.controller("testCtrl", ["$scope", "foo", "boo", function($scope, foo, boo){

foo.get().then(function(response){
$scope.foo = response;
});

boo.get().then(function(response){
$scope.boo = response;
});

// Why this will not work?
function test(){
var getFoo = $scope.foo;
var getBoo = $scope.boo;
};

}]

ऊपर दिया गया उदाहरण काम नहीं कर रहा है, मैं यह काम कैसे कर सकता हूं?

धन्यवाद।

उत्तर:

जवाब के लिए 0 № 1

पार्टी के बाद आए लोगों को। उपयोग किए बिना एक कार्यशील उदाहरण $scope.

hoge.controller("testCtrl", ["$scope", "foo", "boo", function($scope, foo, boo){
function test() {
var getFoo = null;
var getBoo = null;

Promise.all([foo.get(), boo.get()]).then(function(results) {
getFoo = results[0];
getBoo = results[1];
});
};
}]