question: why some of injected services are undefined?
See original GitHub issueThe problem: I have 3 services:
ApiHelper
@Service()
export class ApiHelper {
// contains only methods, none of services are injected
}
LoginService
@Service()
export class SecurityService {
@Inject()
private loginService: LoginService;
}
And SecurityService
@Service()
export class LoginService {
constructor(
private apiHelper: ApiHelper,
private securityService: SecurityService,
) {
console.log(this.securityService); // undefined
console.log(Container.get(SecurityService)); // instance of SecurityService
}
}
And the problem is that securityService is undefined, while Container.get(SecurityService) works good.
What is wrong here?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Angular 7 : Injected service is undefined - Stack Overflow
I can't see the relation between the code in the question, and arrow functions. The OP only talks about constructor s, he nevers...
Read more >Angular injected service is undefined : r/Angular2 - Reddit
Your custom service has the providedIn: 'root' property, but that only tells Angular that it will be a singleton, so only one instance...
Read more >How to Implement Services and Dependency Injection in ...
If a service is injected in any other component, the same instance of the service is available for that component and all it's...
Read more >Angular – Use of access modifier while injection of service
The error is can't access property or function, because particular service is undefined. In my case, I have a function called run() which...
Read more >Inject Service From Another Module in NestJS (2022)
I often read the question of how to inject a service/provider from another module. In this article, I wanna explain how to deal...
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

We’re facing the same issue, same code worked a week ago. Now it gives undefined value from TypeDI.
@attilaorosz Looks like I had some circular dependency due to usage of index.ts… I imported directly without using index.ts, and it started working.