In my Angular application, I have a service that extends an abstract class and implements an abstract method.
@Injectable({
providedIn: 'root',
})
export class ClassB extends ClassA {
constructor(
private service : ExampleService) {
super();
}
abstractMethod() {
//this.service returns undefined here
}
}
export abstract class ClassA {
abstractMethod();
otherMethod() {
this.abstractMethod();
}
}
Nevertheless, in the constructor of ClassB, I face the challenge of injecting a service to be used within the abstract method.
The abstract method is called within "otherMethod()" in the Abstract class. Since the abstractMethod() has no implementation in the Parent class, it expects to find its implementation in the child class, but currently, it returns undefined.
How can I successfully utilize a service instance within the abstractMethod()?
To elaborate, I am striving to access a service instance inside "abstractMethod()", yet it currently results in returning undefined.