- An NgModule declares a compilation context for a set of components that is dedicated to an application domain, a workflow, or a closely related set of capabilities.
- An NgModule can associate its components with related code, such as services, to form functional units.
- The root module,
AppModule, typically resides in a file named
An NgModule is defined by a class with the
@NgModule() decorator, which is a function that tkaes a single metadata object. Some of the most important properties are:
declarations: The components, directives, and pipes that belong to the module.
exports: The subset of
declarationsthat should be visible in the component templates of other modules.
imports: Other modules whose exported classes are needed by component templates declared in this module.