AngularJS Promises, $q, defer

前端 未结 2 1665
天涯浪人
天涯浪人 2020-12-02 10:43

EDIT

The first answer is the elegant one, but, as stated a few times in this question and another questions on stackoverflow, the problem is that th

2条回答
  •  悲&欢浪女
    2020-12-02 11:13

    The $http.get calls are async, but you aren't waiting until they are all completed before resolving the deferred. Here it works with the timeout simply because your are lucky that the calls have time to complete within 1 second, however this isin't reliable at all.

    I will not reiterate a complete solution here, but have a look at my answer for another similar issue.

提交回复
热议问题