inject
function
Injects a token from the currently active injector.
inject
is only supported in an injection context. It
can be used during:
- Construction (via the
constructor
) of a class being instantiated by the DI system, such as an@Injectable
or@Component
. - In the initializer for fields of such classes.
- In the factory function specified for
useFactory
of aProvider
or an@Injectable
. - In the
factory
function specified for anInjectionToken
. - In a stackframe of a function call in a DI context
API
Usage Notes
Jump to details