A module is a container for different part of an App which includes controller, services, filters, directives and many more.
We can also say that it is a collection of controllers, filters, services, directives, etc.
Syntax for creating a module:
var demoModule = angular.module('demoModule', []);
In this, angular.module is a global for creating and retrieving the angular modules.
In this, [] parameter is used to define the dependent modules.
Syntax for adding the controllers, directives and services in the module:
For Services:
demoModule.service('demoService', function(){...});
For Directives:
demoModule.directive("demoDirective", function(){...});
For Controller:
demoModule.controller("demoCtrl", function($scope) {...});
Hope this will help you with module.
0 Comment(s)