Skip to main content

Function: Inject()

Inject(token): PropertyDecorator & ParameterDecorator

Decorator to inject dependencies into constructor parameters or class properties.

When applied to a parameter, stores the custom injection token for that parameter index. When applied to a property, records the injection token to resolve and assign the dependency after instantiation.

Parameters

token

Token

The injection token (class constructor, string, or symbol) to resolve from the DI container.

Returns

PropertyDecorator & ParameterDecorator

A decorator function usable as both a ParameterDecorator and PropertyDecorator.