0

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.

1 Answer 1

2

Angular2 only supports constructor injection.

A workaround that might work for you, is to inject an Injector and get dependencies imperatively

constructor(private injector:Injector) {
  this.xxx = injector.get(SomeType);
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.