Concrete injectors implement this interface. Injectors are configured with providers that associate dependencies of various types with injection tokens.

See

Usage Notes

The following example creates a service injector instance.

{@example core/di/ts/provider_spec.ts region='ConstructorProvider'}

Usage example

{@example core/di/ts/injector_spec.ts region='Injector'}

Injector returns itself when given Injector as a token:

{@example core/di/ts/injector_spec.ts region='injectInjector'}

Public Api

Hierarchy

  • NullInjector

Implements

Constructors

Methods

Constructors

Methods

  • Retrieves an instance from the injector based on the provided token.

    Throws

    When the notFoundValue is undefined or Injector.THROW_IF_NOT_FOUND.

    Parameters

    • token: any
    • notFoundValue: any = THROW_IF_NOT_FOUND

    Returns any

    The instance from the injector if defined, otherwise the notFoundValue.

Generated using TypeDoc