Dependency Injection
Dependency injection can be a difficult concept to fully grasp. However, once you understand the basics, the AngularJS implementation becomes quite clear. Dependency injection is a well-known design pattern in many server-side languages but has not been used much in JavaScript before now.
The idea of AngularJS dependency injection is to define and dynamically inject a dependency object into another object, making available all the functionality provided by the dependency object. AngularJS provides dependency injection through the use of providers and an injector service.
A provider is essentially a definition of how to create an instance of an object with all the necessary functionality. Providers should be defined as part ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access