Expand Minimize

Use inline array annotation for dependency injection in module configs

Use inline array annotation for dependency injection in module configs

CheckId NG1120201
TypeName UseInlineArrayAnnotationForDIInModuleConfigs
Severity CriticalWarning
Type Module config

Using inline array annotation for dependency injection improves the performance of AngularJS injecting dependencies into these functions as it doesn't need to dynamically discover these functions' dependencies.

Good practice

function routeConfigurator($routeProvider) {
    // ...
}

angular.module('app')
    .config(['$routeProvider', routeConfigurator]);


Bad practice
function routeConfigurator($routeProvider) {
    // ...
}

angular.module('app')
    .config(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.