Parameter decorator that injects the instance associated with the given class, or undefined if the class is not registered in the container.
undefined
Parameter decorator that injects the value associated with the given token, or undefined if the token is not registered in the container.
Allows referencing a token that is declared later in the file by using the forwardRef helper function.
class Wizard { constructor(@Optional(forwardRef(() => Wand)) readonly wand: Wand | undefined) {}}// Other code...class Wand {} Copy
class Wizard { constructor(@Optional(forwardRef(() => Wand)) readonly wand: Wand | undefined) {}}// Other code...class Wand {}
Parameter decorator that injects the instance associated with the given class, or
undefined
if the class is not registered in the container.