You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dependency injection in AngularJS is done by providing the names of
the desired dependencies. Providing the same name multiple times is
redundant since the AngularJS injector uses a cache for instantiated
dependencies.
</p>
</overview>
<recommendation>
<p>
Only include the name of each dependency once.
</p>
</recommendation>
<example>
<p>
The following example shows an AngularJS controller with <code>$cookies</code> as a duplicate dependency.
</p>
<samplesrc="examples/DuplicateDependency.js"/>
<p>
This is problematic, since the programmer could be led to believe that the two parameters <code>$cookies1</code> and <code>$cookies2</code> are different instances, which they are not.
</p>
<p>
Instead, the dependency should only be listed once: