[英]How to create promises with the new Breeze Angular Service?
I'm updating my angular/breeze application with the new breeze angular service ( link ) 我正在使用新的微风角度服务( 链接 )更新我的角度/微风应用程序
The documentation explains how to remove the Q.js file and so on. 该文档说明了如何删除Q.js文件等。 But now i'm stuck replacing this method: 但是现在我被卡住替换这种方法:
primePromise = $q.all([getLookups(), getSpeakerPartials()])
.then(extendMetadata)
.then(success);
return primePromise;
or 要么
$q.when();
how should i replace this piece of code with the new breeze angular service? 我应该如何用新的微风角度服务替换这段代码?
You could be worried about two different things. 您可能会担心两件事。
$q
我如何持有$q
$q
is missing critical methods such as .when
and all
我的$q
缺少关键方法,例如.when
和all
You have to inject the $q
service before you can use it as you are showing in your code snippet. 您必须注入$q
服务,然后才能使用它,如代码段所示。 Check the Angular documentation to see how to get it if you don't already know. 查看Angular文档以了解如何获取(如果您还不知道的话)。
As for point #2, make sure you are running with Angular v.1.2 and not an older version! 至于第2点,请确保您使用的是Angular v.1.2,而不是旧版本!
Before v.1.2, $q was extremely limited ... which is why I urged folks to stick to Q.js. 在v.1.2之前,$ q非常有限……这就是为什么我敦促人们坚持使用Q.js。 For example, its promise only offered a then
method. 例如,它的承诺只提供了一个then
方法。
As of v.1.2 , a promise also offers catch
and finally
and $q
has all
and when
methods. 从v.1.2开始 ,promise也提供catch
和finally
而$q
具有all
和when
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.