Angular 2 HttpBackend与Http不兼容



嗨,我有一个提供商正在使用:

构造(http:http,myService:myService,events:events(

在我的单元测试中,我正在调用

provider=新的myProvider(HttpBackend,MyService,Events(

我得到以下信息:

TS2345: Argument of type 'typeof HttpBackend' is not assignable to parameter of type 'Http'.

类型"typeof HttpBackend"中缺少属性"_backend"。

您必须使用@angular/common/http中的HttpClient,而不是Http,并且忘记不要在app.module.ts中包含HttpClientModule

import {HttpClientModule, HttpClient} from '@angular/common/http';

最新更新