Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Injector

whatitdoes

Injector interface

howtouse
const injector: Injector = ...;
injector.get(...);
description

For more details, see the {@linkDocs guide/dependency-injection "Dependency Injection Guide"}.

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'}

stable

Hierarchy

  • Injector

Implemented by

Index

Properties

Methods

Properties

Static NULL

NULL: Injector = new _NullInjector()

Static THROW_IF_NOT_FOUND

THROW_IF_NOT_FOUND: Object = _THROW_IF_NOT_FOUND

Methods

Abstract get

  • get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T): T
  • get(token: any, notFoundValue?: any): any
  • Retrieves an instance from the injector based on the provided token. If not found:

    • Throws {@link NoProviderError} if no notFoundValue that is not equal to Injector.THROW_IF_NOT_FOUND is given
    • Returns the notFoundValue otherwise

    Type parameters

    • T

    Parameters

    Returns T

  • deprecated

    from v4.0.0 use Type or InjectionToken

    suppress

    {duplicate}

    Parameters

    • token: any
    • Optional notFoundValue: any

    Returns any

Generated using TypeDoc