AngularJS Modules


Example

Module serves as a container of different parts of your app such as controllers, services, filters, directives, etc. Modules can be referenced by other modules through Angular's dependency injection mechanism.

Creating a module:

angular
    .module('app', []);

Array [] passed in above example is the list of modules app depends on, if there are no dependencies then we pass Empty Array i.e. [].

Injecting a module as a dependency of another module:

angular.module('app', [
    'app.auth',
    'app.dashboard'
]);

Referencing a module:

angular
    .module('app');