Component Inheritance Angular 2.4

46 views
Skip to first unread message

Ben Mamiya

unread,
Jan 22, 2017, 10:53:23 AM1/22/17
to Angular
@Component({
    selector: 'my-base-component',
    templateUrl: 'my-base-component.html',

})
export class BaseClass implements OnInit, AfterViewInit, AfterViewChecked {
    constructor(protected _serviceA: ServiceA,
    protected _serviceB: ServiceB,
    protected _serviceC: ServiceC,
    protected _serviceD: ServiceD) {
    }
}




export class DerivedClass extends BaseClass {
...logic DerivedClass...
}

Please notice that DerivedClass doesn't have a constructor and therefore is using the BaseClass's one.
Since I upgraded from 2.0.1 to 2.4, I can no longer do that - _serviceA _serviceB etc.. are getting undefined.
I don't have a decorator above the DerivedClass since the only thing that changes is the logic inside the component.

Any thoughts? 

Sander Elias

unread,
Jan 25, 2017, 4:15:21 AM1/25/17
to Angular and AngularJS discussion
Hi Ben,

This is officially permitted since 2.3.0(commit), so it should work. Can you provide a plunk or something similar showing this behaviour? 

Regards
Sander

Reply all
Reply to author
Forward
0 new messages