Simple Angular question.
Should I define an angular module or not? What's the difference if I do it one way or the other?
For example, what's the difference between saying var myApp = angular.module('myFirstApp', []); and angular.module('myFirstApp', []) ?
If I use the 2nd option, I understand all my factories etc have to be dot chained, correct? As in .factory('myFactory', function() {}). But if I use the 1st option and define the angular module, I have to define my factories etc too? as in myApp.factory('myFactory', function() {
}); ?
And if I dot chain (as in the 2nd option), am I then adding everything to the global namespace of the application? But what's the difference between that and defining the module and adding everything to in this case myApp?
Please clarify and explain, sorry for the super simple question, I think the answer to this can tie a lot together for me.
Thank you.
Edit: I think some of my question above can be paraphrased in the following way: What's the difference between using the full angular.module() as getter each time and a global variable? Why should a global variable be avoided?