Skip to content

Instantly share code, notes, and snippets.

@M4R1KU
Last active March 8, 2017 11:20
Show Gist options
  • Save M4R1KU/20359bd6bebfe0a9b0107d82ed729fbc to your computer and use it in GitHub Desktop.
Save M4R1KU/20359bd6bebfe0a9b0107d82ed729fbc to your computer and use it in GitHub Desktop.
export function translationLoader(translateService: TranslateService): () => Promise<any> {
translateService.setDefaultLang('en');
return () => translateService.use(translateService.getBrowserLang()).toPromise();
}
@NgModule({
declarations: [
AppComponent
],
imports: [
HttpModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: translateFactory,
deps: [Http]
})
],
providers: [
{
provide: APP_INITIALIZER,
useFactory: translationLoader,
deps: [TranslateService],
multi: true
}
],
bootstrap: [AppComponent]
})
export class AppModule {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment