加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – Angular $q.when如何工作?

发布时间:2020-12-17 09:06:35 所属栏目:安全 来源:网络整理
导读:可以有人解释我$ q.when如何工作在AngularJS? 我试图分析如何$ http工作,并发现这: var promise = $q.when(config); 这里是来自Chrome控制台的配置对象: Object {transformRequest: Array[1],transformResponse: Array[1],cache: Object,method: "GET",u
可以有人解释我$ q.when如何工作在AngularJS?
我试图分析如何$ http工作,并发现这:
var promise = $q.when(config);

这里是来自Chrome控制台的配置对象:

Object {transformRequest: Array[1],transformResponse: Array[1],cache: Object,method: "GET",url: "/schedule/month_index.html"…}
cache: Object
headers: Object
method: "GET"
transformRequest: Array[1]
transformResponse: Array[1]
url: "/schedule/month_index.html"
__proto__: Object

接下来发生什么?这个对象如何解决或拒绝?

调用$ q.when需要一个promise或任何其他类型,如果它不是一个promise,那么它将它包装在promise和调用resolve。如果你传递一个值给它,那么它永远不会被拒绝。

从文档:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读