I have a series of input boxes that are inside of an element and I want to make the parent element of the input boxes to individually have a border based on where the mouse is focused. The code looks like this:
HTML (just one of the input elements, because they are all coded the same way):
<div class="parent-element">
<input type="text"
[class.bordered]="myBooleanVariable"
(focus)="addBorder()"
(blur)="removeBorder()"
/>
</div>
TypeScript:
addBorder() {
this.myBooleanVariable = true;
}
removeBorder(event) {
this.myBooleanVariable = false;
}
The problem that I am having is that when the bordered class is applied on focus, all of the .parent-element divs get borders since myBooleanVariable is either true or false. I want to avoid making static variables like myBooleanVariable1, myBooleanVariable2, etc.
How can I accomplish this?