I'm looking for some community feedback on the topic of SEFs/IIFEs and 
Angular 1.2x. Some things I have read seem to lean heavily on the side of 
using them everywhere, no matter what, if you are writing JavaScript. In 
jQuery I feel this was true, as well as for raw JS, but I just don't see 
the need to use them with Angular. This is because I believe that Angular 
already encapsulates things when controllers etc. are defined if you do it 
right. By this, I mean writing:

window.myApp = angular.module('myApp', []);

myApp.controller('controller1', ['$scope', function($scope){
//this stuff is encapsulated so why use a SEF?
}]);

as opposed to:

(function(){
angular.module('myApp').controller('controller1', controllerFunction);
controllerFunction.$inject = ['$scope'];

function controllerFunction($scope){
//this stuff is not encapsulated and needs a SEF
}
})();

Concerns of minification aside, is one way better than the other or is this 
just a matter of personal preference? FWIW, I prefer the first method and 
the lack of a SEF but I want to make sure that the project is done right 
from a technical point of view and not cater to personal preferences.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to