In our Angular App we have Feature Modules as well as Core and Shared Module as described by the Angular - linkStyle Structure best practices.
We use ng2-translate
and as per doc, we should call forRoot()
in App Module (root module).
This is how our App Module looks like:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
FeatureAModule,
FeatureBModule,
CoreModule,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [Http]
})
],
bootstrap: [AppComponent]
})
export class AppModule { }
As we want to translate our menu and it's part of the Core Module we had to import the Translate Module there, like so:
@NgModule({
imports: [
TranslateModule
],
exports: [
FormsModule,
MenuComponent,
BreadcrumbComponent
],
declarations: [MenuComponent, BreadcrumbComponent]
})
export class CoreModule {
constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
throwIfAlreadyLoaded(parentModule, "CoreModule");
}
}
Does this make sense? Should I remove TranslateModule.forRoot(...)
from the App Module and place it in the imports of the Core Module ? Is that wrong?