Last active
March 13, 2019 06:29
-
-
Save enappd/cb0c5135635565043f69ee6e96a967cb to your computer and use it in GitHub Desktop.
Setup ngx-translate and http-loader in app.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule, ErrorHandler } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { RouteReuseStrategy } from '@angular/router'; | |
import { HttpClientModule, HttpClient } from '@angular/common/http'; | |
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; | |
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; | |
import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; | |
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | |
import { StatusBar } from '@ionic-native/status-bar/ngx'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app.component'; | |
export function HttpLoaderFactory(http: HttpClient) { | |
return new TranslateHttpLoader(http, "./assets/i18n/", ".json"); | |
} | |
@NgModule({ | |
declarations: [AppComponent], | |
entryComponents: [], | |
imports: [BrowserModule, | |
HttpClientModule, | |
TranslateModule.forRoot({ | |
loader: { | |
provide: TranslateLoader, | |
useFactory: HttpLoaderFactory, | |
deps: [HttpClient] | |
} | |
}), | |
IonicModule.forRoot(), | |
AppRoutingModule], | |
providers: [ | |
StatusBar, | |
SplashScreen, | |
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy } | |
], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment