Let's say I have a variable called isVisible. And I have a method called
ReverseVariable(variable: boolean)
{
variable = !variable;
}
I want to call this method from a template like
<button (click)="ReverseVariable(isVisible)"></button>
I want to give it isVisible in the parameters and have isVisible reverse itself. Something like the following example is not an option
ReverseVisibility()
{
this.isVisible = !this.isVisible;
}
Is there any way that I can pass the variable by reference?
isVisiblea property of the component? Do you say thatthis.isVisible = !this.isVisibleis not an option because the variable name needs to be dynamic or because the variable doesn't belong to thethiscontext?