@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 Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

What Are the Purpose of @NgModule? What Are the Purpose of @NgModule? Reviewed by Anil Singh on 3:28 AM Rating: (5)
www.code-sample.com/. Powered by Blogger.
^