Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I wondering in Angular 2 if there is a way in angular2 to resolve dependency without going to constructor. In .net you can inject dependency in 3 ways (Constructor, setter, interface-based). Can I also do a setter injection on angular2 ts.
Angular2 only supports constructor injection.
A workaround that might work for you, is to inject an Injector and get dependencies imperatively
Injector
constructor(private injector:Injector) { this.xxx = injector.get(SomeType); }
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.