21. Understanding AngularJS Modules and Dependency Injection

One of the most important aspects of AngularJS to understand is dependency injection and how it relates to modules. Dependency is a common concept across many server-side languages but has not really been implemented much in JavaScript until AngularJS.

Dependency injection allows AngularJS modules to maintain a very clean, organized form and yet more easily access functionality from other modules. When implemented correctly, it also tends to reduce the amount of code by a considerable amount.

This chapter provides a basic overview of dependency injection and then describes how to create modules that provide functionality and how to consume that functionality in other modules as well ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.