@angular/core

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 a Provider or an @Injectable.
  • In the factory function specified for an InjectionToken.
  • In a stackframe of a function call in a DI context
  
    
  
  
Jump to details