Injectable
Decorator that marks a class as a provider. Providers can be injected into other classes via constructor parameter injection using Nest's built-in Dependency Injection (DI) system.
@Injectable(options?: ScopeOptions)
Parameters
Option | Type | Description |
---|---|---|
options
|
ScopeOptions |
options specifying scope of injectable
|
Returns
ClassDecorator
See also
Description
When injecting a provider, it must be visible within the module scope (loosely speaking, the containing module) of the class it is being injected into. This can be done by:
- defining the provider in the same module scope
- exporting the provider from one module scope and importing that module into the module scope of the class being injected into
- exporting the provider from a module that is marked as global using the
@Global()
decorator
Providers can also be defined in a more explicit and imperative form using various custom provider techniques that expose more capabilities of the DI system.