7.7 KiB
NgModule API
Prerequisites
A basic understanding of the following concepts:
Purpose of @NgModule
At a high level, NgModules are a way to organize Angular apps
and they accomplish this through the metadata in the @NgModule
decorator. The metadata falls
into three categories:
- Static: Compiler configuration which tells the compiler about directive selectors and where in templates the directives should be applied through selector matching. This is configured via the
declarationsarray. - Runtime: Injector configuration via the
providersarray. - Composability/Grouping: Bringing NgModules together and making them available via the
importsandexportsarrays.
@NgModule({
// Static, that is compiler configuration
declarations: [], // Configure the selectors
entryComponents: [], // Generate the host factory
// Runtime, or injector configuration
providers: [], // Runtime injector configuration
// Composability / Grouping
imports: [], // composing NgModules together
exports: [] // making NgModules available to other parts of the app
})
@NgModule metadata
The following table summarizes the NgModule metadata properties.
| Property | Description |
|---|---|
declarations
|
|
providers
|
|
imports
|
|
exports
|
|
bootstrap
|
|
entryComponents
|
That leaves only components bootstrapped using one of the imperative techniques, such as |
More on NgModules
You may also be interested in the following: