I wonder if it is worth writing angular stuff this way:
(function(angular, module) {
'use strict';
module.controller('MyCtrl', function($scope) {
// possibly use helperFunction here
});
function helperFunction() {
...
}
})(angular, angular.module('myModule'));
or this way (using App object and putting app stuff into it:
App = App || {};
App.myModule = App.myModule || angular.module('myModule', []);
App.myModule.controller('MyCtrl', function($scope) {
'use strict'
// possibly use helperFunction here
function helperFunction() {
...
}
});
than using regular way like this
angular.module('myModule').controller('MyCtrl', function($scope) {
'use strict'
// possibly use helperFunction here
function helperFunction() {
...
}
});
Those are three possible ways (not counting requirejs) of structuring app code that come to my mind. I'm using "regular" one (the last) as seen in most places, but I wonder if there are any benefits of using those two former approaches. Maybe there are special cases when those are useful, I'm not aware of.