What is NgModule?
NgModule is the main building block of an Angular application, represented as a class with the @NgModule decorator. It organizes the application into logical units and manages the dependencies between them.
The main functions of NgModule:
- Declarations - a list of components, directives, and pipes that belong to this module.
- Imports - connecting other modules to use their components, directives, or services.
- Exports - specifies what from this module can be made available to other modules.
- Providers - services available through dependency injection within the module.
- Bootstrap - the root component from which the application starts (only in the root module).
NgModule lets you structure the application, manage dependencies, and reuse functionality across modules.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.