@NgModule decorator

What Are the Purpose of @NgModule?

What Are the Purpose of @NgModule?
The NgModule is used to simplify the ways you define and manage the dependencies in your applications and also you can consolidate different components and services into cohesive blocks of functionality.

The @NgModule metadata divided into three categories as follows.
1.          Static
2.          Runtime
3.          Composability/Grouping

Static – It is compiler configuration and configured via the declarations array.

Runtime - It is injector configuration and configured via the provider’s array.

Composability/Grouping – Introducing NgModules together and configured via the imports and exports arrays.

The following is an example of specifying a NgModule metadata -
@NgModule({
  // Static, This is the compiler configuration
  declarations: [], //declarations is used for configure the selectors.
  entryComponents: [], //entryComponents is used to generate the host factory.

  //Runtime or injector configuration
  providers: [], // providers is used for runtime injector configuration.

  //Composability and Grouping
  imports: [], // imports used for composing NgModules together.
  exports: [] //A list of declarations components, directives, and pipes classes that an importing module can use.
})

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.
^