How can I share dependency injection between child and parent components with the new Angular.
eg. I want to move the AlertService to the parent component and leave the TraingCompanyService in the derived component
Current component
@Component({ selector: 'wk-training-company-edit', template: require('./edit.html') }) export class TrainingCompanyEditComponent implements OnInit, OnDestroy { constructor( private alert: AlertService, private trainingCompanyService: TrainingCompanyService ) { } }
Reorganized Components (V1)
Super need to be called before calling this in the constructor of the derived class
@Component({ selector: 'wk-training-company-edit', template: require('./edit.html') }) export class TrainingCompanyEditComponent extends BaseAdminEditComponent implements OnInit, OnDestroy { constructor( private alert: AlertService, private trainingCompanyService: TrainingCompanyService ) {
Reorganized Components (V2)
The TrainingCompanyEditComponent class incorrectly extends the base class BaseAdminEditComponent, types have separate private property warning declarations'
@Component({ selector: 'wk-training-company-edit', template: require('./edit.html') }) export class TrainingCompanyEditComponent extends BaseAdminEditComponent implements OnInit, OnDestroy {
Reorganized Components (V3)
It works, just wondering if this is the best method.
@Component({ selector: 'wk-training-company-edit', template: require('./edit.html') }) export class TrainingCompanyEditComponent extends BaseAdminEditComponent implements OnInit, OnDestroy {