correct me If I am wrong..
--Setting a module
var app = angular.module("myapp", []);
// here brackets means module does't exist just go and create it, and the empty array is the list of module it depends on
--Getting a module
var app = angular.module("myapp");
//and if brackets are not here mean module exist just find it.
but what is the difference between below lines:-
var myapp = angular.module("myapp", []);
myapp.controller("MyController", "$scope", [function($scope){
//TODO
}]);
and
angular.module("myapp", [])
.controller("MyController", "$scope", [function($scope){
//TODO
}]);
I think we should use variable only if our module is divided in multiple files. but I am not sure if it will really makes any difference.
As per Angular Style Guide we should not use variable while declaring a module.Could anyone please clarify?
Thanks
myappin your first example? Also, your second example would not work, you would need to chain the controller definition with the module definition in the previous line (hint: no semicolon, noappvariable). Leaving these two issues aside, both examples are equivalent and produce the same result.