python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
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

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions