Aug 9, 2017 · 1 min read
Hello, thanks for the step by step explanation of this implementation (I had it on an Ionic 2 project but not understanding it well).
Unfortunately, I am trying to implement it on an Angular 4 application but it is not working, same issue as the other comments:
Argument of type ‘Http’ is not assignable to parameter of type ‘HttpClient’. Property ‘handler’ is missing in type ‘Http’.
I tried to figured it out but don’t understand what is the problem.. Here is my app module:
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';import { HttpModule, Http } from '@angular/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';import { HomeModule } from './home/home.module';
import { NotFoundComponent } from './not-found/not-found.component';
import { PrivateModule } from './private/private.module';
import { UserService } from './user.service';// ERROR APPENDS HERE.
export function createTranslateLoader(http: Http) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
declarations: [
AppComponent,
NotFoundComponent
],
imports: [
BrowserAnimationsModule,
HttpModule,
AppRoutingModule,
PrivateModule,
HomeModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http]
}
})
],
providers: [UserService, Http],
bootstrap: [AppComponent]
})
export class AppModule { }
I am not importing the BrowserModule as BrowserAnimationsModule is already importing it. Thanks for you help.
