Inheritance and dependency injection

后端 未结 7 1419
时光说笑
时光说笑 2020-11-28 04:38

I have a set of angular2 components that should all get some service injected. My first thought was that it would be best to create a super class and inject the service ther

7条回答
  •  一个人的身影
    2020-11-28 05:18

    From what I understand in order to inherit from base class you first need to instantiate it. In order to instantiate it you need to pass its constructor required parameters thus you pass them from child to parent thru a super() call so it makes sense. Injector of course is another viable solution.

提交回复
热议问题