@Wrybread wrote:
I have a grid of buttons, and I’m trying to change the background color of the most recently clicked button, but have the other buttons not have that background. Ideally I’d like to add a style to the most recently clicked button, and remove that style from all other buttons.
Currently my buttons are defined like this:
<ion-col size="6" class="mainButton" (click)="DoStuff(1, true)"> <img src="assets/images/icon-aurora.png" height=70> </ion-col>
I’m still wrapping my head around Ionic so please forgive anything silly that I’m doing. Here’s the function call (currently not working):
DoStuff(data: string, swapBg: boolean = false) { if (swapBg) { this.style.backgroundColor = '#345465'; } return;
Any tips to change the background color of just the button that was clicked? Ideally without having to make a separate variable for each of the buttons, since I have a lot of them?
Is there some way to pass the ID of the clicked button, using “this”?
Posts: 2
Participants: 2