Well, I'm structuring my project following the infrastructure of:
- Feature module.
- Core module.
- Shared module.
But there's something that I still don't have clear enough.
As far as I know, the HttpClientModule should be in the CoreModule because well,... it provides the HttpClient service to make HTTP requests to a server.
Now, the imports array allows an Angular module to use functionalities provided in other modules, and the exports array allows an Angular module to expose some of its functionalities.
I have this in my CoreModule:
@NgModule({
imports: [
BrowserAnimationsModule,
HttpClientModule,
RouterModule.forRoot(routes, {
enableTracing: true
})
],
exports: [
RouterModule
]
})
export class CoreModule {
}
Now, since my CoreModule is imported in my AppModule, shouldn't the HttpClientModule and BrowserAnimationsModule be exported as well? Just as the RouterModule.
I'm seeing the CoreModule and SharedModule like some sort of bridge.
The SharedModule makes more sense to me:
@NgModule({
imports: [
MatButtonModule
],
exports: [
MatButtonModule
]
})
export class SharedModule {
}
The SharedModule imports the MatButtonModule and then export it so that other modules can make use of it.
Shouldn't the CoreModule be the same way? Because the App runs fine; however, I'm in dev-mode.
Hope I was clear enough and someone can help me to brush out this doubt.