I note that in Module's document we've a new decorator @Global().
If I set a module as Global, How do I use it in another module without import?
Here is the version informations:
"@nestjs/common": "^4.5.6",
"@nestjs/core": "^4.5.7",
As I understand It has to be imported at least once somewhere in the app.
In my case, I have global ConfigModule with exported ConfigService.
I import it at the root AppModule along with all other modules: DbModule, LoggerModule, FormsModule. Now I can just inject ConfigService in all my modules, without importing the ConfigModule everywere
@myflowpl Thanks for your sharing. But if I have to import the class(not interface) that I want to use, why we use DI? why not just new className() and call its method with the instance?
@sirius1024 it's all about testing.
@sirius1024 it's nicely explained here https://angular.io/guide/dependency-injection#di-by-example
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
As I understand It has to be imported at least once somewhere in the app.
In my case, I have global ConfigModule with exported ConfigService.
I import it at the root AppModule along with all other modules: DbModule, LoggerModule, FormsModule. Now I can just inject ConfigService in all my modules, without importing the ConfigModule everywere