Dependency Injection (DI) is one of the best
features of AngularJS. It makes our lives easier by letting us write loosely
coupled and easily testable components. The DI framework's in charge of
creating components, resolving their dependencies, and passing them to other
components when requested. You've already seen many examples of Dependency
Injection. This chapter covers two core AngularJS services called
$injector that work in
the background to make Dependency Injection possible.
Components may obtain their dependencies in the following two ways:
new on a constructor function to
obtain their dependency themselves.
By using a global variable to look up dependencies. ...