angular / 14.0.0 / api / core / environmentinjector.html /

EnvironmentInjector

class developer preview

An Injector that's part of the environment injector hierarchy, which exists outside of the component tree.

abstract class EnvironmentInjector implements Injector {
  abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T
  abstract destroy(): void
}

Methods

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

abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T

Parameters
token ProviderToken<T>
notFoundValue T

Optional. Default is undefined.

flags InjectFlags

Optional. Default is undefined.

Returns

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

Throws

Error When the notFoundValue is undefined or Injector.THROW_IF_NOT_FOUND.

abstract get(token: any, notFoundValue?: any): any

Deprecated from v4.0.0 use ProviderToken

Parameters
token any
notFoundValue any

Optional. Default is undefined.

Returns

any

abstract destroy(): void

Parameters

There are no parameters.

Returns

void

© 2010–2022 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/core/EnvironmentInjector