

Number of injected dependencies matches the number of function parameters in filters |
When injecting dependencies in filters ensure that they match the function parameters
CheckId | NG1010602 |
---|---|
TypeName | NumberOfInjectedDependenciesMatchesNumberOfFunctionParametersInFilters |
Severity | CriticalError |
Type | Filter |
When injecting dependencies in filters ensure that the specified dependencies match the function parameters. Any additional parameters specified in the function, will be omitted and AngularJS won't assign any dependencies to them.
Bad practice ($rootScope not specified amongst dependencies to inject)
angular
.module('app')
.directive('relativeUrl', ['$scope', function($scope, $rootScope) {
}]);
.module('app')
.directive('relativeUrl', ['$scope', function($scope, $rootScope) {
}]);
Good practice
angular
.module('app')
.directive('relativeUrl', ['$scope', '$rootScope', function($scope, $rootScope) {
}]);
.module('app')
.directive('relativeUrl', ['$scope', '$rootScope', function($scope, $rootScope) {
}]);
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.