In Angular, a module is a class marked by @NgModule decorator that contains components, directives, pipes, and services.
An Angular application has at least one module.
import { NgModule } from '@angular/core';
@NgModule({
declarations: ...,
imports: ...,
exports: ...,
providers: ...,
bootstrap: ...
})
class MyModule {}
- Declarations: List of components, directives, and pipes that belong to this module.
declarations: [HelloComponent, TranslatePipe]
- Imports: List of modules to import into this module. Everything from the imported modules (components, directives, pipes) is available to the declarations of this module.
imports: [BrowserModule, SomeOtherModule]
- Exports: List of components, directives, and pipes visible to modules that import this module.
exports: [HelloComponent, TranslatePipe]
- Providers: List of dependency injection providers visible both to the contents of this module and to importers of this module.
providers: [ApiService, { provide: UserService }]
- Bootstrap: List of components to bootstrap when this module is bootstrapped.
bootstrap: [HelloComponent]
Top comments (0)