打字稿异步/等待和角度$ q服务 [英] Typescript async/await and angular $q service

查看:80
本文介绍了打字稿异步/等待和角度$ q服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

是否可以将TypeScript异步/等待功能与$q服务承诺一起使用?

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;
        }]);

这篇关于打字稿异步/等待和角度$ q服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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