Two div elements have values 1 and 2. Every time when each element is clicked I want to toggle css class. This provided solution always toggle css class for both (all) elements.
<div (click)="toggleClass()" [class.active]="isActive">1</div>
<div (click)="toggleClass()" [class.active]="isActive">2</div>
export class MyComponent{
isActive = false;
constructor(){}
toggleClass() {
this.isActive = !this.isActive;
}
}