Angular 2 HttpBackend not compatible with Http

时间:2018-07-25 04:34:28

标签: angular typescript karma-jasmine

Hi I have a provider that is using:

construct(http: Http, myService: MyService, events:Events)

In my unit test I am calling

provider = new myProvider(HttpBackend, MyService, Events)

I am getting the following:

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

Property '_backend' is missing in type 'typeof HttpBackend'.

1 个答案:

答案 0 :(得分:0)

you have to use HttpClient from @angular/common/http, instead of Http and forget not to include HttpClientModule in app.module.ts

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