[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/core/runInInjectionContext [Back]  [Original]

runInInjectionContext Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/core

runInInjectionContext

function
stable

Runs the given function in the context of the given Injector.

Run within an injection context

On this page

    arrow_upward_alt Back to the top

    API

    function runInInjectionContext<ReturnT>(
      injector: Injector,
      fn: () => ReturnT,
    ): ReturnT;
    @paraminjectorInjector

    the injector which will satisfy calls to inject while fn is executing

    @paramfn() => ReturnT

    the closure to be run in the context of injector

    @returnsReturnT

    the return value of the function, if any

    Description

    Runs the given function in the context of the given Injector.

    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.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page