Created
May 22, 2013 14:05
-
-
Save kadamwhite/5627762 to your computer and use it in GitHub Desktop.
AngularJS Declaration Conventions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.directive('myDirective', [ | |
'$compile', | |
'$location', | |
'Notify', | |
'sharedData', | |
function($compile, $location, Notify, sharedData) { | |
// do stuff | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.directive('myDirective', [ | |
'$location', | |
'$compile', | |
'Notify', | |
'sharedData', | |
function($location, $compile, Notify, sharedData) { | |
// do stuff | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.directive('myDirective', [ | |
'$compile', | |
'$location', | |
'Notify', | |
'sharedData', | |
function( | |
$compile, | |
$location, | |
Notify, | |
sharedData | |
) { | |
// do stuff | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.directive('myDirective', ['$location', '$compile', 'Notify', 'sharedData', function($location, $compile, Notify, sharedData) { | |
// do stuff | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.directive('myDirective', ['$location', '$compile', 'Notify', 'sharedData', | |
function($location, $compile, Notify, sharedData) { | |
// do stuff | |
} | |
); |
Agreed we need to fix this. I am okay with multline-dependencies-alphabetical or just straight multiline-dependencies. The only reason I'm not 100% into alphabetical is that it's alphabetical-with-priority-on-native-Angular. Seems a little over complex.
The angular-first came for free b/c I was assuming symbols preceded letters—I'm fine either way. Adam and Jason seem to be on-board with either multi-line everything or multi-line alpha.
Yeah when I run sort-lines in my editor the angular modules bubble to the top because of the $ symbol.
Note that for most controllers this will result in $scope
not coming first. This is acceptable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We've been regularly seeing merge conflicts on Angular module, service, directive and controller definitions, as dependencies are commonly added and removed from these lines. I've been talking with Brendan about ways we could solve this problem through convention, and made this gist to kick-start the discussion.
Personally I lean towards multi-line dependencies, alphabetically ordered (with native Angular services first)—this avoids the
) {
of the fully multi-line approach while minimizing conflicts in the dependency array.Thoughts and Strong Opinions welcome.