mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Errors I've documented so far: - `$injector:cdep` - `$injector:itkn` - `$injector:modulerr` - `$injector:nomod` - `$injector:pget` - `$injector:unpr` - `ng:areq` - `ng:cpi` - `ng:cpws` - `ngModel:noass` Closes #3430
26 lines
No EOL
789 B
Text
26 lines
No EOL
789 B
Text
@ngdoc error
|
|
@name $injector:cdep
|
|
@fullName Circular Dependency
|
|
@description
|
|
|
|
This error occurs when the {@link api/angular.injector $injector} tries to get
|
|
a service that depends on itself, either directly or indirectly. To fix this,
|
|
construct your dependency chain such that there are no circular dependencies.
|
|
|
|
For example:
|
|
|
|
```
|
|
angular.module('myApp', [])
|
|
.factory('myService', function (myService) {
|
|
// ...
|
|
})
|
|
.controller('MyCtrl', function ($scope, myService) {
|
|
// ...
|
|
});
|
|
```
|
|
|
|
When an instance of `MyCtrl` is created, the service `myService` will be created
|
|
by the `$injector`. `myService` depends on itself, which causes the `$injector`
|
|
to detect a circular dependency and throw the error.
|
|
|
|
For more information, see the {@link guide/di Dependency Injection Guide}. |