Posts

What are NgModules?

 An NgModule is a TypeScript class decorated with @NgModule that tells Angular: Which components, directives, and pipes belong together Which other modules this module depends on Which parts should be exposed to other modules Which component should bootstrap the application (for root modules) import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; @NgModule({   declarations: [AppComponent],   imports: [BrowserModule],   providers: [],   bootstrap: [AppComponent] }) export class AppModule {} Types of NgModules 📌 Root Module Usually AppModule Entry point of the app 📌 Feature Modules Group related functionality Example: UserModule , AdminModule 📌 Shared Module Common components/pipes used across the app Example: buttons, headers 📌 Core Module Singleton services (auth, logging) Imported once only