Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    Sadly, this won't make Logger to be injected automagically when the class is instantiated directly like that, new Teacher(...). Commented Sep 16, 2016 at 21:06
  • I don't know what you want to do exactly. What I understood is that you want your Logger to be an optional dependency, for that you need to annotate the logger in the constructor with @Optional(). Commented Sep 17, 2016 at 0:43
  • The question explains how Teacher class is supposed to be used. The injector would throw on Teacher class from your example, because other constructor annotations (public name: String, private age: number) are not providers. Commented Sep 17, 2016 at 0:58