Skip to main content

Dependency Injection for Angulars

Dependency injection in Angular is the system that creates services and hands them to the classes that need them. Providers describe how a dependency is built, injectors form a hierarchy that decides which instance is shared, and the inject function or constructor parameters request them. It keeps logic reusable and easy to replace in tests.

Stage: Services and Data · Part of the Angular roadmap · Last reviewed 19 November 2026

What to learn in Dependency Injection

Dependency Injection interview questions

What does providedIn: 'root' do?

It registers the service with the root injector, so one shared instance exists for the whole application. It also makes the service tree-shakable, because it is only included in the bundle if something injects it. Narrower scopes are possible by providing it in a component or route instead.

When would you use an InjectionToken?

Use an InjectionToken when the dependency is not a class, such as a configuration object, a string or an interface, because those have no runtime type Angular can use as a key. The token acts as the lookup key, and you can attach a default factory.

Where Dependency Injection fits in the Angular roadmap

Dependency Injection belongs to the Services and Data stage (intermediate level), which takes about 24 hours. Share logic.

Back to the full Angular roadmap