2013-12-15 2 views
1

제목에 언급 된대로 두 건의 약속이있는 $q.all()을 호출하면 첫 번째 결과 만 수신됩니다. 이것은 내가하고있는 것입니다 :

$q.all(resouce1.getAll(), resource2.getAll()).then(function (res1, res2) { 
    // only output one object which contains the result from the first promise 
    // if I swap the two promise, the result is still the first one. 
    // can't really get both results at the same time 
    console.log(arguments);  
}); 

어떤 도움을 주실 수 있습니다.

답변

4
$q.all([resouce1.getAll(), resource2.getAll()]).then(function (res) { 
    console.log(res);  
}); 

all는 약속의 배열 또는 해시를 허용하고 하나의 어레이 결과에 함수를 호출한다.

+0

:). 굉장해. 나는 대신에 배열을 전달하는 지점을 놓쳤다. 너 정말 고마워. – bingjie2680

관련 문제