V
V
Vladimir Golub2020-12-14 11:54:34
Node.js
Vladimir Golub, 2020-12-14 11:54:34

Why use @Inject in nestjs?

There is a module in the service of which I want to use another module.
What will be the difference between records?

@Inject('Enum')
    private readonly EnumService: Enum

and
private readonly EnumService: Enum

if in both cases it is necessary to prescribe module imports ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-12-14
@RazerVG

https://docs.nestjs.com/providers#property-based-i...

If your class doesn't extend another provider, you should always prefer using constructor-based injection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question