background preloader

Front-end

Facebook Twitter

Egghead.io - Learn AngularJS with Tutorial Videos & Training @eggheadio. How do I "think in AngularJS" if I have a jQuery background? AngularJS. Angular History. Angular Intro. Dependency Injection. Loading... Improve this doc Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies. The Angular injector subsystem is in charge of creating components, resolving their dependencies, and providing them to other components as requested. For in-depth discussion about DI, see Dependency Injection at Wikipedia, Inversion of Control by Martin Fowler, or read about DI in your favorite software design pattern book.

DI in a Nutshell There are only three ways a component (object or function) can get a hold of its dependencies: The component can create the dependency, typically using the new operator.The component can look up the dependency, by referring to a global variable.The component can have the dependency passed to it where it is needed. The first two options of creating or looking up dependencies are not optimal because they hard code the dependency to the component. Here is an example of using the injector service: For example: Three.js. Famo.us.