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.
})