I know this is close to duplicating
Are named functions or anonymous functions preferred in JavaScript?
or the even more popular
var functionName = function() {} vs function functionName() {}
(to name a few) questions, but after reading neither really satisfactorily answers my question. I think I understand the difference between function expressions, named function expressions, and function declarations (well, almost understand...).
When I create directives, my usual style is something like this:
angular.directive('myDirective', function() {
return {
...
controller: function($scope){
}
};
});
Looking at a lot of the angular.js source, it seems they prefer
angular.directive('myDirective', function() {
return {
...
controller: function myDirectiveCtrl($scope){
}
};
});
I would think this might be useful if you are going to use myDirectiveCtrl inside of itself, but this isn't the case for most angular directives.
Is this just a style choice or is there an advantage or reason for using named function expressions when declaring controllers, link functions, etc.?