-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best way for long controller $inject #833
Comments
First, I use a max size line of 120 chars in my source code. If the controller declaration goes away 120 chars, i fold line before the limit then i fold the Example : MainController.$inject = [
'Api', 'segments', 'ResourceService', 'AdminService','SweetAlertService', 'UsersCsvService',
'UsersSearchService', 'CriteriaService'
];
function MainController(Api, segments, ResourceService, AdminService, SweetAlertService, UsersCsvService,
UsersSearchService, CriteriaService) {
// code here
} In this example with a 120 chars line, i could have this : MainController.$inject = [
'Api', 'segments', 'ResourceService', 'AdminService','SweetAlertService', 'UsersCsvService', 'UsersSearchService',
'CriteriaService'
];
function MainController(Api, segments, ResourceService, AdminService, SweetAlertService, UsersCsvService,
UsersSearchService, CriteriaService) {
// code here
} But to keep consistency between I am not sure your |
Thanks for your answer. Why |
For IMHO there is no reason to inject them except when a third party library that you must use needs them to communicate with events. You have to keep in mind that scopes does not exist anymore in Angular. So if you want to handle your technical debt you need to keep consistency in your projects between AngularJS and Angular to allow a future migration when AngularJS will become deprecated. For events, you should read this discussion. |
Ok, I note it. |
@amiceli A nice alternative is ng-annotate which eliminates the need for lengthy $inject arrays:
|
@bampakoa thanks @MarcLoupias An another question, without |
Read this discussion. IMHO, |
For example with this controller :
What's best way for too long $inject array and/or controller arguments ?
For controller is it a very bad idea to use arguments ?
Or use an alias :
Thanks.
The text was updated successfully, but these errors were encountered: