.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 :(得分:0)
对于参加聚会后的人们。一个不使用$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];
});
};
}]