Typescript async/await 和 angular $q 服务 [英] Typescript async/await and angular $q service

查看:36
本文介绍了Typescript async/await 和 angular $q 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的 TypeScript 异步/等待功能使用 ES6 承诺.AngularJS 使用 $q 服务承诺,界面略有不同.

New TypeScript async/await feature uses ES6 promises. AngularJS uses $q service promises with slightly different interface.

有没有什么方法可以使用带有 $q 服务承诺的 TypeScript 异步/等待功能?

Is there any way to use TypeScript async/await feature with $q service promises?

推荐答案

你可以让它像这样工作:

You can make it work like this:

angular.module('your app')
        .run(['$window', '$q', function($window, $q) {
            $window.Promise = $q;
        }]);

这篇关于Typescript async/await 和 angular $q 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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