O'Reilly logo

AngularJS: Novice to Ninja by Sandeep Panda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12Dependency Injection In AngularJS

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 $provide and $injector that work in the background to make Dependency Injection possible.

A Brief Recap

Components may obtain their dependencies in the following two ways:

  1. By invoking new on a constructor function to obtain their dependency themselves.

  2. By using a global variable to look up dependencies. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required