Should you import BrowserModule or CommonModule?
BrowserModule
– Most of all browser applications should import BrowserModule from @angular/platform-browser and the BrowserModule
provides services that are important to launch and run your browser apps.
Do not import BrowserModule in any other module.
BrowserModule also re-exports CommonModule from @angular/common and CommonModule is used when you want to use
directives - NgIf, NgFor and may more.
BrowserModule exports a couple of NgModules like
-
exports:
[
CommonModule,
ApplicationModule
]
And
//AppModule class with the @NgModule
decorator
@NgModule({
declarations: [
AppComponent,
LoginComponent,
MyPipe,
MyDirective
],
imports: [//DOM
rendering, sanitization, and location
BrowserModule
],
providers: [//service
providers
MySericeService,
MyModuleModule
],
bootstrap: [AppComponent], // bootstrapped
entry component
exports: [
CommonModule,
ApplicationModule
]
})
export
class AppModule
{
//exporting app module
}