0

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?

2
  • 1
    Did you check if isButtonDisabled() is actually being called? Commented Jan 10, 2022 at 11:47
  • it is called for sure Commented Jan 10, 2022 at 12:00

2 Answers 2

1

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;
Sign up to request clarification or add additional context in comments.

1 Comment

thanks I will try it
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.