2013-07-13 00:42:27 +00:00
|
|
|
@ngdoc error
|
|
|
|
|
@name $injector:itkn
|
|
|
|
|
@fullName Bad Injection Token
|
|
|
|
|
@description
|
2013-08-01 22:11:10 +00:00
|
|
|
|
|
|
|
|
This error occurs when using a bad token as a dependency injection annotation.
|
|
|
|
|
Dependency injection annotation tokens should always be strings. Using any other
|
|
|
|
|
type will cause this error to be thrown.
|
|
|
|
|
|
|
|
|
|
Examples of code with bad injection tokens include:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
var myCtrl = function ($scope, $http) { /* ... */ };
|
|
|
|
|
myCtrl.$inject = ['$scope', 42];
|
|
|
|
|
|
|
|
|
|
myAppModule.controller('MyCtrl', ['$scope', {}, function ($scope, $timeout) {
|
|
|
|
|
// ...
|
|
|
|
|
}]);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The bad injection tokens are `42` in the first example and `{}` in the second.
|
|
|
|
|
To avoid the error, always use string literals for dependency injection annotation
|
|
|
|
|
tokens.
|
|
|
|
|
|
|
|
|
|
For an explanation of what injection annotations are and how to use them, refer
|
|
|
|
|
to the {@link guide/di Dependency Injection Guide}.
|