function
Runs the given function in the context of the given Injector
.
runInInjectionContext<ReturnT>(injector: Injector, fn: () => ReturnT): ReturnT
injector | Injector | the injector which will satisfy calls to |
fn | () => ReturnT | the closure to be run in the context of |
ReturnT
: the return value of the function, if any
Within the function's stack frame, inject
can be used to inject dependencies from the given Injector
. Note that inject
is only usable synchronously, and cannot be used in any asynchronous callbacks or after any await
points.
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/core/runInInjectionContext