Services and Dependency Injection

Control whether a dependency is global or isolated to part of the component tree.

  1. Dependency Injection Hierarchy

    Understand environment, root, route, component, and element injectors.

  2. Facade Service Pattern

    Hide complex state and API coordination behind a simple service interface.

  3. inject Function and Injection Context

    Use inject() correctly and understand where an injection context exists.

  4. InjectionToken

    Inject configuration and non-class dependencies with strongly typed tokens.

  5. Optional, Self, SkipSelf, and Host

    Control how Angular resolves dependencies through the injector hierarchy.

  6. Provider Configuration

    Use class, value, factory, existing, and multi providers correctly.

  7. Services and Dependency Injection

    Understand how Angular services contain reusable logic and how Dependency Injection provides those services to components and other application features.

  8. Singleton Service Patterns

    Choose the correct provider scope for application-wide and feature-specific services.