According to AngularJS's tutorial, a controller function just sits within the global scope.
http://docs.angularjs.org/tutorial/step_04
Do the controller functions themselves automatically get parsed into an encapsulated scope, or do they dwell within the global scope? I know that they are passed a reference to their own $scope, but it appears that the function themselves are just sitting in the global scope. Obviously this can cause problems down the road, and I have learned through experience and education to encapsulate Further more, if they do dwell within the global scope, would it not be considered a best practice to encapsulate them within an object to be referenced like this:
Object.functionName();
Rather than this:
functionName();
So as to prevent issues that occur with the pollution of the global scope (ie overriding functions, etc..)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…