Last active
March 8, 2017 11:20
-
-
Save M4R1KU/20359bd6bebfe0a9b0107d82ed729fbc to your computer and use it in GitHub Desktop.
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
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