How to create module in angularjs and What is the use of module in angularjs?

How to create module in angularjs and What is the use of module in angularjs?


?
1
2
3
4
5
var app= angular.module("MyApp", []);
//The above (with [] module) is indicate that this a setter function its used for register a module.
var app= angular.module("MyApp");
//The above (without [] module) is indicate that this is getter function and its used for retrieve a previously registered module.
var app= angular.module("MyApp", []);
//The above (with [] module) is indicate that this a setter function its used for register a module.

var app= angular.module("MyApp");
//The above (without [] module) is indicate that this is getter function and its used for retrieve a previously registered module.
Example. The given below explain about basic concept of module.
?
1
2
3
4
5
6
var app = angular.module("MyApp", []).controller("contr1", function(){}); // module MyApp has controller contr1.
var app = angular.module("MyApp").controller("contr2", function(){}); // module MyApp has controllers contr1, contr2.
var app = angular.module("MyApp", []); // module MyApp  registered to this module.
app.controller("contr3", function(){}); // module MyApp has controller contr3 only.
var app = angular.module("MyApp", []).controller("contr1", function(){}); // module MyApp has controller contr1.

var app = angular.module("MyApp").controller("contr2", function(){}); // module MyApp has controllers contr1, contr2.

var app = angular.module("MyApp", []); // module MyApp  registered to this module.
app.controller("contr3", function(){}); // module MyApp has controller contr3 only.
ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.