John P
John P

Reputation: 1221

Typescript inherit a variable from superclass

Let's say I have 2 components:

export class BaseComponent {
    succesfullSave: boolean;
}


export class InheritComponent extends BaseComponent {
    isButtonDisabled() {
        return !super.succesfullSave;
    }
}

in my InheritComponent html, I have a button with a disabled directive:

<button [disabled]="isButtonDisabled()"></button>

After changing the succesfullSave property value, the button is still enabled.

Angular doesn't look for value change when inheriting a value from superclass?

Upvotes: 0

Views: 662

Answers (2)

ghybs
ghybs

Reputation: 53225

Should be just this.succesfullSave.

You need super. to access a method of your base class, but you have overridden it in your child (extending) class.

Upvotes: 1

Algidaq Elemgdadi
Algidaq Elemgdadi

Reputation: 94

disable attribute accepts a value not a functional. So i think creating a get property would a solve the issue.

get isButtonDisabled():boolean=>!super.succesfullSave;

Upvotes: 1

Related Questions