---
title: "What is an AngularJS module?"  
description: "What is an AngularJS module?"  
author: "Sandra Emily"  
published: 2024-06-24  
updated: 2024-06-25  
canonical: https://www.mindstick.com/forum/160775/what-is-an-angularjs-module  
category: "angular js"  
tags: ["web development", "angular js", "front-end development"]  
reading_time: 2 minutes  

---

# What is an AngularJS module?

What is an AngularJS module?

## Replies

### Reply by Ravi Vishwakarma

An [**AngularJS module**](https://www.mindstick.com/blog/304413/angularjs-expressions-and-modules#google_vignette) is a **container** for different parts of an **application**, **such as controllers**, **services**, **filters**, **directives**, and more. It helps in organizing the application into cohesive blocks of functionality. Modules provide a namespace for your application, and they can be used to load different parts of your application in a controlled way.

## Syntax

```javascript
var app = angular.module('myApp', [dependencies]);
```

## Example-

```javascript
var app = angular.module('myApp', []);
```

#### Adding Components to a Module

After creating a module, you can add components to it, such as controllers, services, directives, filters, etc.

**Adding a** [**Controller**](https://www.mindstick.com/blog/304403/angularjs-controllers-and-scope)

```javascript
app.controller('MainController', ['$scope', function($scope) {
    $scope.message = "Hello, World!";
}]);
```

## Adding Service

```javascript
app.service('MathService', function() {
    this.add = function(a, b) {
        return a + b;
    };
});
```

## Adding Factory

```javascript
app.factory('StringFactory', function() {
    var factory = {};
    factory.toUpperCase = function(str) {
        return str.toUpperCase();
    };
    return factory;
});
```

## Features and Benefits of AngularJS Modules

1. **Modularity**: Organizes code into manageable and logical units.
2. **Reusability**: Facilitates reuse of modules across different applications.
3. **Dependency Management**: Manages dependencies between different parts of the application, ensuring that all necessary components are loaded.
4. **Separation of Concerns**: Keeps different aspects of the application **separated**, improving maintainability and readability.


---

Original Source: https://www.mindstick.com/forum/160775/what-is-an-angularjs-module

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
