
- Angular Tutorial
- Angular - Home
- Angular - Overview
- Angular - Features
- Angular - Advantages & Disadvantages
- Angular Basics
- Angular - Environment setup
- Angular - First Application
- Angular - MVC Architecture
- Angular Components
- Angular - Components
- Angular - Component Lifecycle
- Angular - View Encapsulation
- Angular - Component Interaction
- Angular - Component Styles
- Angular - Nested Components
- Angular - Content projection
- Angular - Dynamic components
- Angular - Elements
- Angular Templates
- Angular - Templates
- Angular - Template statements
- Angular - Template Variables
- Angular - SVG as Templates
- Angular Binding
- Angular - Data Binding
- Angular - Interpolation
- Angular - Event Binding
- Angular - Property Binding
- Angular - Attribute Binding
- Angular - Class Binding
- Angular - Style Binding
- Angular - Two-way Binding
- Angular Directives
- Angular - Directives
- Angular - Attribute Directives
- Angular - Structural Directives
- Angular - Custom Directives
- Angular Pipes
- Angular - Pipes
- Angular - Built-in Pipes
- Angular - Custom Pipes
- Angular Forms
- Angular - Forms
- Angular - Template Driven Forms
- Angular - Reactive Forms
- Angular - Form Validation
- Angular - Dynamic Forms
- Angular Dependency Injection
- Angular - Dependency Injection
- Angular - Injectable Service
- Angular Routing
- Angular - Routing
- Angular - Dynamic Routes
- Angular - Wildcard Routes
- Angular - Nested Routes
- Angular - Navigation
- Angular - Routing in SPA
- Angular - Custom Route Matches
- Angular - Router Reference
- Angular HTTP Client programming
- Angular - Services
- Angular - HTTP Client
- Angular - Request
- Angular - Response
- Angular - GET
- Angular - POST
- Angular - PUT
- Angular - DELETE
- Angular - JSONP
- Angular - CRUD Operations Using HTTP
- Angular Modules
- Angular - Introduction to Modules
- Angular - Root Module
- Angular - Feature Module
- Angular - Sharing Module
- Angular - Routing Module
- Angular - NgModules
- Angular Animation
- Angular - Animations
- Angular Service Workers & PWA
- Angular - Service Workers & PWA
- Angular Testing
- Angular - Testing Overview
- Angular Design Patterns
- Angular - Design Patterns
- Angular - Lazy Loading
- Angular - Singleton Pattern
- Angular - Observer Pattern
- Angular Libraries
- Angular - Libraries
- Angular - Angular Material
- Angular - PrimeNG
- Angular - RxJS
- Angular Advanced
- Angular - Signals
- Angular - Authentication & Authorization
- Angular - Internationalization
- Angular - Standalone Component
- Angular - Accessibility
- Angular - Web Workers
- Angular - Server Side Rendering
- Angular - Ivy Compiler
- Angular - Building with Bazel
- Angular - Backward Compatibility
- Angular - Reactive Programming
- Angular Tools
- Angular - CLI
- Angular Material UI Elements
- Angular - Paginator
- Angular - Datepicker
- Angular - Select Drop-down
- Angular Miscellaneous
- Angular - Third Party Controls
- Angular - Configuration
- Angular - Displaying Data
- Angular - Decorators & Metadata
- Angular - Basic Example
- Angular - Error Handling
- Angular - Testing & Building a Project
- Angular - Lifecycle Hooks
- Angular - User Input
- Angular - What's New?
- Angular Useful Resources
- Angular - Quick Guide
- Angular - Useful Resources
- Angular - Discussion
Angular - Modules
Angular modules are core concepts in Angular application, which help to organize the application structure by grouping the related components, services, etc.
In this chapter, we will learn about the angular module, its importance in the application, how to create a module, and how to use it in our application in detail.
What are Angular Modules?
In Angular, a module refers to a place or container where you can group the components, directives, pipes, and services, which are related to the application. This helps organize the application, making it easier to understand and manage dependencies efficiently.
For example, if you are developing a website or an application, the header, footer, left, center, and right sections become part of a module. However, they are not modules themselves, they are individual components that belong to that module.
Types of Angular Modules
Following is a list of commonly used Angular modules −
Importance of Angular Modules
In Angular, a module plays an important role in "structuring an Angular application", making it easier for others to understand by simply viewing the application's hierarchy. An application is considered well-structured if each concern (say component or section) is separated into its own module.
For example, login and signup components can belong to an Authentication module.
How to Create an Angular Module?
To create an Angular module, you must have a basic understanding of thefirst Angular applicationcreation and about CLI, etc. Here are the step-by-step guides to creating an Angular module in an application:
Step 1: In your code editor (such as VS Code) open any existing angular application or create new one. (See how to...)
Step 2: Open the "terminal" in your code editor and go to your application directory as follows:
cd application_directory e.g.... cd myapp
Step 3: Now create a new module using the following command:
ng generate module auth
Here, auth is your "module name".
Once the above command is executed successfully, you may see:
CREATE src/app/auth/auth.module.ts (202 bytes)
Step 4: Toggle the Auth folder you may able to see the auth.module.ts file with some default code as follows:
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; @NgModule({ declarations: [], imports: [ CommonModule ] }) export class AuthModule { }
How to use Angular Module?
As we have already created a new module named "auth" in our application. To use it properly in our angular application follow the steps below:
Step 1: Import Module
Import the newly created module within your root module (older version) or in the component (recent version) of your application as follows:
import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AuthModule } from './auth/auth.module'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, AuthModule], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { }
Step 2: Create Components
Now create "two" different components named login and signup as follows:
ng g c auth/login --no-standalone ng g c auth/signup --no-standalone
Note: Make sure that the component within the @NgModule should be "no standalone", otherwise, you may get an "error".
Step 3: Import and Export the components
Open the auth.module.ts file and import both the components within the @NgModule as follows:
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SignupComponent } from './signup/signup.component'; import { LoginComponent } from './login/login.component'; @NgModule({ declarations: [SignupComponent, LoginComponent], imports: [ CommonModule ], exports: [LoginComponent, SignupComponent] }) export class AuthModule { }
Step 4: Use Components in your Templates
You can now use the LoginComponent and SignupComponent in your templates. For example, in the app.component.html file, you can include the following:
<app-login></app-login> <app-signup></app-signup>
Step 5: Run Application
Finally, run the application to see the output:
ng serve
Step 6: Navigate to localhost:4200
Open your friendly browser (e.g chrome) and navigate through the localhost:4200.

As you can see in the above picture the the login and signup components belongs to AuthModule.
Conclusion
In conclusion, the Angular modules are important for building "scalable", "maintainable", and structured applications. Modules in Angular help organize and structure your code, making it easier to manage and understand.