The identifier used to resolve the class in the DI container.
Optional
init: true | InitDelegate<T, U>Optional an initializer function to transform the dependency before injection or true to instantiate the dependency if it has a constructor.
If true, throws an error if the dependency is not found.
The resolved dependency or undefined if the dependency is not necessary and not found, or throws an error if the dependency is necessary and not found.
Only throws errors if the dependency is necessary.
A DependencyResolutionError if the dependency is not found.
A InjectorError if an error occurs during the injection process.
A NoInstantiationMethodError if the dependency does not have a constructor.
An InitializationError if an error occurs during the initialization process.
class MyClass {
@Inject<MyDependency>('MyDependencyIdentifier')
private myDependency!: MyDependency;
}
class MyClass {
@Inject('ILogger_', (x: ILogger_) => x.getLogger('Tags'), false)
private _logger?: ILogger;
}
A decorator to inject a dependency from a DI (Dependency Injection) container into a class property.