I have a requirement to pass the 'name' variable from the Derived component to the constructor of the Base Component. The purpose is to enforce that Derived components extending from the Base components must provide the 'name' variable.
@Component({
selector: 'base-component',
templateUrl: './base.component.html',
styleUrls: ['./base.component.scss']
})
export class BaseComponent {
public name: string;
constructor(public sampleName: string) {
this.name = sampleName;
}
}
In my Derived component, I am importing the 'name' variable from a separate file named name.enum.ts
export enum Name {
NAME = 'DummyName'
}
Here is my derived component:
import {Name} from ../name.enum
@Component({
selector: 'derived-component',
templateUrl: './derived.component.html',
styleUrls: ['./derived.component.scss']
})
export class DerivedComponent extends BaseComponent {
constructor() {
super(Name.NAME); //However, this results in an error stating 'Can't resolve all parameters for BaseComponent'
}
How can I resolve this issue?