Please enable Javascript to correctly display the contents on Dot Net Tricks!


Posted On : 05 Feb 2015
Updated On : 04 Apr 2015
Total Views : 7632

AngularJS modules are containers just like namespace in C#. They divide an angular app into small, reusable and functional components which can be integrated with other angular app. Each module is identified by a unique name and can be dependent on other modules. In AngularJS, every web page (view) can have a single module assigned to it via ng-app directive.

Creating an AngularJS module

<script type="text/javascript"> 
// defining module 
angular.module('myApp', []); 

//OR defining module which has dependency on other modules 
angular.module('myApp', ['dependentModule1', 'dependentModule2']); 

Using an AngularJS module into your app

<html ng-app="myApp"> 

Modules Components

You can define following components with in your angular module:

  1. Directive

  2. Filter

  3. Controller

  4. Factory

  5. Service

  6. Provider

  7. Value

  8. Config settings and Routes

What do you think?

I hope you will have better understanding of module in AngularJS. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.