Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Angular 4 ngx-translate : Argument of type 'HttpClient' is not assignable to parameter of type 'Http'. Type 'HttpClient' is missing the following properties from type 'Http': _backend, _defaultOptions #82

Open
Priya-mani09 opened this issue Sep 8, 2020 · 0 comments

Comments

@Priya-mani09
Copy link

Im implementing ngx-translate in Angular 4 application.

The versions used are

"@ngx-translate/core": "^7.0.0", 
"@ngx-translate/http-loader": "^0.1.0"

And my app.module.ts looks like this

import { HttpClientModule, HttpClient } from '@angular/common/http';
import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, '../../assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    AppComponent,
    DatabaseReinstallComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    HttpModule,
    .... ,
    ... ,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: (createTranslateLoader),
        deps: [HttpClient]
      }
    })
  ],
  exports: [TranslateModule],
  bootstrap: [AppComponent],
  providers: [ ... , HttpClient, TranslateService],
  schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule { }

I have installed the translate versions as per the version compatibility table. Im using Angular 4.
But still getting the error
Argument of type 'HttpClient' is not assignable to parameter of type 'Http'.
Type 'HttpClient' is missing the following properties from type 'Http': _backend, _defaultOptions

Im not able to figure out why it comes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant