EnvironmentInjector
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 get<T>(token: ProviderToken<T>, notFoundValue: null, options: InjectOptions): T | null
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T
abstract get(token: any, notFoundValue?: any): any
abstract runInContext<ReturnT>(fn: () => ReturnT): ReturnT
abstract destroy(): void
}
Methods
get() | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Retrieves an instance from the injector based on the provided token. |
||||||||||||||||||||||||||||||||||||
|
token
|
ProviderToken<T> |
|
notFoundValue
|
undefined |
|
options
|
InjectOptions & { optional?: false; } |
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
.
Overload #1
abstract get<T>(token: ProviderToken<T>, notFoundValue: null, options: InjectOptions): T | null
Parameters
token
|
ProviderToken<T> |
|
notFoundValue
|
null |
|
options
|
InjectOptions |
Returns
T | null
: The instance from the injector if defined, otherwise the notFoundValue
.
Throws
Error
When the notFoundValue
is undefined
or Injector.THROW_IF_NOT_FOUND
.
Overload #2
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T
Parameters
token
|
ProviderToken<T> |
|
notFoundValue
|
T |
Optional. Default is |
options
|
InjectOptions |
Optional. Default is |
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
.
Overload #3
abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T
Deprecated use object-based flags (InjectOptions
) instead.
Parameters
token
|
ProviderToken<T> |
|
notFoundValue
|
T |
Optional. Default is |
flags
|
InjectFlags |
Optional. Default is |
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
.
Overload #4
runInContext() | |||
---|---|---|---|
Runs the given function in the context of this |
|||
Deprecated use the standalone function Parameters
Returns
|
|||
Within the function's stack frame, |
destroy() |
---|
ParametersThere are no parameters. Returns
|