Skip to main content

What is Dependency Injection (DI) and how does Angular implement it?

Junior Angular
Quick Answer Angular DI: services are registered in providers and instantiated by the Angular injector. When a component declares a dependency in its constructor, Angular looks up the injector tree for a provider. providedIn: "root" creates a singleton for the whole app. Component-level providers create a new instance per component instance. Child injectors inherit from parent injectors.

Answer

Dependency Injection provides required objects (services) to classes instead of creating them internally.

Angular uses injectors, providers, and a hierarchical DI system. Constructor injection is the most common mechanism.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice