knowhow-server
Version:
A personal workflow engine that can manage and use any network connected host
25 lines (24 loc) • 1.45 kB
HTML
<a href="http://github.com/angular/angular.js/edit/master/docs/content/error/injector/cdep.ngdoc" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">Circular Dependency</code>
<div><span class="hint">error in component <code ng:non-bindable="">$injector</code>
</span>
</div>
</h1>
<div><pre class="minerr-errmsg" error-display="Circular dependency found: {0}">Circular dependency found: {0}</pre>
<h2 id="description">Description</h2>
<div class="description"><div class="-injector-page -injector-cdep-page"><p>This error occurs when the <a href="api/angular.injector"><code>$injector</code></a> 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.</p>
<p>For example:</p>
<pre><code>angular.module('myApp', [])
.factory('myService', function (myService) {
// ...
})
.controller('MyCtrl', function ($scope, myService) {
// ...
});</code></pre>
<p>When an instance of <code>MyCtrl</code> is created, the service <code>myService</code> will be created
by the <code>$injector</code>. <code>myService</code> depends on itself, which causes the <code>$injector</code>
to detect a circular dependency and throw the error.</p>
<p>For more information, see the <a href="guide/di">Dependency Injection Guide</a>.</p>
</div></div>
</div>