Skip to main content

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:

  1. Declarations - a list of components, directives, and pipes that belong to this module.
  2. Imports - connecting other modules to use their components, directives, or services.
  3. Exports - specifies what from this module can be made available to other modules.
  4. Providers - services available through dependency injection within the module.
  5. 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 ready
Premium

A concise answer to help you respond confidently on this topic during an interview.