0

I want to make something actions in function only when variable is true. This changeAddressPermision variable changes in popup - when user click cancel changeAddressPermision is false, and when user click confirm changeAddressPermision is true. Popup looks like this:

<div *ngIf="!isPopupClosed" class="popup">
    <p class="popup__text">Are you sure you want to change address?</p>
    <div class="popup-button__div">
        <button class="popup__button" (click)="isPopupClosed = true; changeAddressPermision = true">Yes</button>
        <button class="popup__button" (click)="isPopupClosed = true; changeAddressPermision = false">Cancel</button>
    </div>
</div>

It should work like this: Function x listen to variable change - if user click Yes - popup close and function x do something based on changeAddressPermision. It should wait for user click on popup and if user click something - its do something based if changeAddressPermision == false or true

1 Answer 1

1

You can achieve that by adding setter/getter for changeAddressPermision like the following:

set changeAddressPermision(value: boolean) {
    this._changeAddressPermision = value;

    if (value) {
        // do something here if value is true
    } else {
        // do something here if value is false
    }
}
get changeAddressPermision(): boolean {
    return this._changeAddressPermision;
}
private _changeAddressPermision: boolean;
Sign up to request clarification or add additional context in comments.

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.