class
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: undefined, options: InjectOptions & { optional?: false; }): T
abstract runInContext<ReturnT>(fn: () => ReturnT): ReturnT
abstract destroy(): void
} | get() | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Retrieves an instance from the injector based on the provided token. | ||||||||||||||||||||||||||||||||||||||||||
|
token | ProviderToken<T> | |
notFoundValue | undefined | |
options | InjectOptions & { optional?: false; } |
T: The instance from the injector if defined, otherwise the notFoundValue.
Error When the notFoundValue is undefined or Injector.THROW_IF_NOT_FOUND.
abstract get<T>(token: ProviderToken<T>, notFoundValue: null, options: InjectOptions): T | null token | ProviderToken<T> | |
notFoundValue | null | |
options | InjectOptions |
T | null: The instance from the injector if defined, otherwise the notFoundValue.
Error When the notFoundValue is undefined or Injector.THROW_IF_NOT_FOUND.
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T token | ProviderToken<T> | |
notFoundValue | T | Optional. Default is |
options | InjectOptions | Optional. Default is |
T: The instance from the injector if defined, otherwise the notFoundValue.
Error When the notFoundValue is undefined or Injector.THROW_IF_NOT_FOUND.
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): TDeprecated use object-based flags (InjectOptions) instead.
token | ProviderToken<T> | |
notFoundValue | T | Optional. Default is |
flags | InjectFlags | Optional. Default is |
T: The instance from the injector if defined, otherwise the notFoundValue.
Error When the notFoundValue is undefined or Injector.THROW_IF_NOT_FOUND.
abstract get(token: any, notFoundValue?: any): anyDeprecated from v4.0.0 use ProviderToken
token | any | |
notFoundValue | any | Optional. Default is |
any
| runInContext() Deprecated | |||
|---|---|---|---|
| Runs the given function in the context of this | |||
|
fn | () => ReturnT | the closure to be run in the context of this injector |
ReturnT: the return value of the function, if any
Within the function's stack frame, inject can be used to inject dependencies from this injector. Note that inject is only usable synchronously, and cannot be used in any asynchronous callbacks or after any await points.
| destroy() |
|---|
|
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/core/EnvironmentInjector