• Overview
@angular/core

Injector

Class

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

  
    abstract class Injector {
}

get

5 overloads

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

@paramtokenProviderToken<T>
@paramnotFoundValueundefined
@paramoptionsInjectOptions & { optional?: false | undefined; }
@returnsT

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

@paramtokenProviderToken<T>
@paramnotFoundValuenull | undefined
@paramoptionsInjectOptions
@returnsT | null

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

@paramtokenProviderToken<T>
@paramnotFoundValueT | undefined
@paramoptionsInjectFlags | InjectOptions | undefined
@returnsT

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

@deprecated

use object-based flags (InjectOptions) instead.

@paramtokenProviderToken<T>
@paramnotFoundValueT | undefined
@paramflagsInjectFlags | undefined
@returnsT
@deprecated

from v4.0.0 use ProviderToken

@paramtokenany
@paramnotFoundValueany
@returnsany

THROW_IF_NOT_FOUND

{}

create

2 overloads
@deprecated

from v5 use the new signature Injector.create(options)

@paramprovidersStaticProvider[]
@paramparentInjector | undefined
@returnsInjector

Creates a new injector instance that provides one or more dependencies, according to a given type or types of StaticProvider.

@paramoptions{ providers: (any[] | TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider)[]; parent?: Injector | undefined; name?: string | undefined; }

An object with the following properties:

  • providers: An array of providers of the StaticProvider type.
  • parent: (optional) A parent injector.
  • name: (optional) A developer-defined identifying name for the new injector.
@returnsInjector
Jump to details