

Inject built-in AngularJS dependencies before custom ones in module configs |
Inject built-in AngularJS dependencies before custom ones in module configs
CheckId | NG1050201 |
---|---|
TypeName | InjectBuiltInDependenciesBeforeCustomOnesInModuleConfigs |
Severity | CriticalWarning |
Type | Module config |
When inject dependencies into module configuration, inject the built-in AngularJS dependencies first, followed by your custom ones. This will make the code easier to read and maintain.
Good practice
function routeConfigurator($routeProvider, baseUrl) {
// ...
}
angular.module('app')
.config(['$routeProvider', 'baseUrl', routeConfigurator]);
// ...
}
angular.module('app')
.config(['$routeProvider', 'baseUrl', routeConfigurator]);
Bad practice
function routeConfigurator(baseUrl, $routeProvider) {
// ...
}
angular.module('app')
.config(['baseUrl', '$routeProvider', routeConfigurator]);
// ...
}
angular.module('app')
.config(['baseUrl', '$routeProvider', routeConfigurator]);
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.