AngularJS Tutorial 6 - Modules

Опубликовано: 17 Октябрь 2024
на канале: Nisha Singla
1,798
30

In this video we are going to cover Modules in angularJS.
Modules are one of the most important part of any angularJS application. Modules act like a container for different parts of your application like routes, controller, filters,directives,services etc.

How to create Module

var app = angular.module("mainApp",[]);
Creating module is quiet easy and straight forward. So to create module you need to use angular object's module method.
module method takes two parameter- first parameter is the name of the module and second the list of dependencies.
Module may have dependency on another modules, so you need to pass all module names in second parameter on which your main module is dependent.
If you module is not dependent on any other modules , you need to pass empty array in 2nd parameter of module() method.

How to use module in shell page

Now to refer your "mainApp" module in shell page so that all the associated controllers,filters,directives can load as soon as your angular will load you need to use this module in ng-app directive

ng-app = "mainApp"

Further in the coming videos we will bind controllers on this module

To visit all my videos on angularJS Please visit this link:

   • AngularJS Tutorial 1  -  Introduction