The code is as below:
class BaseClass {
propertyA: KnockoutObservable<string> = ko.observable<string>();
constructor(message: string) {
this.propertyA.subscribe((newValue)=>{
console.log(newValue); // not run when change propertyA in ChildClassA instance.
});
}
}
class ChildClassA extends BaseClass {
propertyA: KnockoutObservable<string> = ko.observable<string>(); //remove it, the issue is solved.
}
I noticed that when the ChildClassA has the same property named as the BaseClass, the subscription function for propertyA will not run. Remove that line of declaration in ChildClassA will solved the issue.
Why?