Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It has to be super simple but I just cannot get it at all. I have a base class, and then a class which inherits from base class. Base class has a c-tor, child class does not. Base class is never provided, only child class. Child class has one single boolean property, which should be initialized to some value, doesn't matter at that point.
However, when child class is injected into, for example, a component, this property is undefined.

What I have tried:

Base class:
@Injectable()
export abstract class BaseClass {
   constructor(private x: MyService){}
   abstract test(): void;
}


Child class:
@Injectable()
export class ChildClass extends BaseClass {
    myProp: boolean = false;
    test(): void {
        console.log(this.myProp); // undefined
    }
}


Any ideas anyone?
Posted
Updated 29-Mar-22 2:08am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900