How does Angular $q.when work?

后端 未结 1 1912
粉色の甜心
粉色の甜心 2021-01-30 15:31

Can some one explain me how does $q.when work in AngularJS? I\'m trying to analyse how $http work and found this:

var promise = $q.when         


        
相关标签:
1条回答
  • 2021-01-30 16:10

    Calling $q.when takes a promise or any other type, if it is not a promise then it will wrap it in a promise and call resolve. If you pass a value to it then it is never going to be rejected.

    From the docs:

    Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.

    0 讨论(0)
提交回复
热议问题