While working with Angular, I encountered an issue where rendering multiple images using the img tag resulted in all images changing background color when one of them was clicked. I need to find a solution to change only the background color of the image that is clicked.
Below is the code snippet I am currently using:
html
<img
[src]="data.Url" alt="image"
(click)="_upload(data.Url)"
[ngClass]="{'green' : toggle, 'red': !toggle}"
>
ts
Within my function:
this.toggle = !this.toggle;
this.status = this.toggle ? 'Enable' : 'Disable';