简体   繁体   中英

Can we use a common service without module into other module (specifically controller) in NestJs?

I am working on a NestJs project. There are different modules. I want to have a common service without module that can b used anywhere in the app. Is it possible to use a common service without module? If yes then how can i use it? Actually i want to use different functions from a service.

if you want to use service term you need to register @Injectable() service to a module you can register it to app.module.ts, but it depends on what common.service.ts exactly do?

if you want to use a dependency injection mechanism of Nestjs you should add @Injectable and a Scope then register it into whatever module do you want.

if you got the answer plz vote me up:), if not leave a comment with more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM