MyInternships.in

Angular Basics

Angular Modules NgModule

An NgModule groups related components, directives and pipes, declares what they can use, and exposes what other modules may import. It was the organising unit of Angular before standalone components.


What is Modules NgModule in Angular?

An NgModule groups related components, directives and pipes, declares what they can use, and exposes what other modules may import. It was the organising unit of Angular before standalone components.

Modules NgModule example

A classic NgModule
TypeScript
@NgModule({
  declarations: [AppComponent, JobCardComponent],   // what belongs to this module
  imports: [BrowserModule, HttpClientModule, FormsModule],  // what it needs
  providers: [ApiService],                          // services
  bootstrap: [AppComponent],                        // root component
})
export class AppModule {}

Key points to remember

  • A component may be declared in exactly one NgModule.
  • Feature modules plus lazy loading were the standard architecture before standalone.
  • You still need to read NgModules to maintain existing applications.

The four arrays

ArrayHolds
declarationscomponents, directives and pipes owned by this module
importsother modules whose exports this module needs
exportswhat this module makes available to importers
providersservices registered for injection

Common mistakes with Modules NgModule

  • Declaring the same component in two modules, which throws at compile time.
  • Forgetting to export a component, so importing modules cannot use it.

Angular Modules NgModule— Interview Questions & FAQs

Should I learn NgModules in 2026?+

Learn standalone first because it is the default for new work, then learn enough NgModule syntax to maintain older codebases — which is most of the enterprise Angular in production today.

Related Angular Topics

Keep learning with these closely related lessons.

Ready to use your Angular skills?

Find verified Angular internships and fresher developer jobs across India.

Browse Angular Internships