@Inject() doesn't work and why should i use Container.get()
See original GitHub issuewhy should i use Container.get() Am I using typedi wrong way?
t.ts
export class T {
@Inject("userService") private userService!:UserService;
constructor(){}
}
service.ts
@Service("userService")
export class UserServiceImpl implements UserService{
}
run.ts
export default function index(){
const passport =new T();
// const passport = Container.get(Passport); why should i use Container.get()
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
TypeDI @Inject() doesn't work, but Container.get() does
You need to create your instance of SomeClass using Container#get , or the container won't be able to inject the property.
Read more >Dependency injection and inversion of control in Python
When you call the main() function the Service dependency is assembled and injected automatically. When you do testing, you call the container.api_client.
Read more >Introduction to Contexts and Dependency Injection - Quarkus
This is a scope annotation. It tells the container which context to associate the bean instance with. In this particular case, a single...
Read more >InversifyJS a powerful IoC container for JavaScript apps ...
A IoC container uses a class constructor to identify and inject its dependencies. InversifyJS has a friendly API and encourage the usage of...
Read more >PHP definitions
$containerBuilder->addDefinitions([ // place your definitions here ]); ... Do not use new (e.g. new DI\create() ) or you will get a fatal error...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah I think it doesn’t need to be flagged as a service technically. It will just use the Type as the identifier for a class in the simple case.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.