AngularJs Modules
AngularJS Modules
You might now be wondering, what are modules ?
Let us discuss about modules and their relevance, before seeing more about controllers.
- AngularJS follows the module pattern.
- It segregates our application code into the reusable components.
- This helps to package the complete application code into reusable modules, like we do packaging of server side code.
- It makes development, maintenance and testing of Angular application easier.
- Every module should ideally be in its own js file. Ideally, the file name should match with module name.
For Example :
- Name of Angular Module: app
- Name of js file where the module is defined: app.js
Let us see now look into how modules can be created in AngularJS.
The method angular.module() is used to create a module in AngularJS, as shown below.