Using Angular 5 and TypeScript, in the following inheritance scenario, is it possible to not have to include MyService as an argument to the constructor of MyComponent?
export class CBasic {
// properties and methods
}
export class CAdvanced extends CBasic {
// constructor
constructor(
public myService: MyService
) {
// call constructor of super-class (required)
super();
}
// more properties and methods
}
export class MyComponent extends CAdvanced {
// constructor
constructor() {
// call constructor of super-class (required)
super(); // Error: [ts] Expected 1 arguments, but got 0.
}
}
The error I am getting is [ts] Expected 1 arguments, but got 0. in MyComponent.
The point is I want to include MyService in CAdvanced to avoid code-duplication in classes that inherit from it, e.g. MyComponent.
MyComponentdo anything else? If not, you can just remove it.