获得角的状态延迟? [英] Get state of Angular deferred?

查看:169
本文介绍了获得角的状态延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery deferreds我曾经是能够检查当前的状态是这样的:

With jQuery deferreds I'm used to be able to check the current state like this:

var defer = $.Deferred();
defer.state();  //Returns the state of the deferred, eg 'resolved'

有没有办法做同样的角度deferreds? (甚至更好的承诺)

Is there a way to do the same for Angular deferreds? (or even better promises)

推荐答案

更新

由于$ Q的重构,这是可能的,现在虽然没有记载:

Due to refactoring of $q this is now possible although not documented:

promise.$$state.status === 0 // pending
promise.$$state.status === 1 // resolved
promise.$$state.status === 2 // rejected

原始

不像大多数承诺库(蓝鸟,Q的时候,RSVP等),$ Q不公开的同步检查API。

Unlike most promise libraries (Bluebird,Q, when, RSVP etc), $q does not expose a synchronous inspection API.

有没有办法从外部实现这一

There is no way to achieve this from the outside.

您必须调用。然后在该处理程序的承诺,code时的承诺履行将运行。

You have to call .then on the promise and code in that handler will run when the promise fulfills.

这篇关于获得角的状态延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆