Angular 4 vs. Angular 5

Should you import BrowserModule or CommonModule?

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
}
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.
^