I have a list of elements which looks like :
<ul *ngFor="let period of periodsDate">
<li
[class.show]="isShown" (click)="toggleClass()">
<a>{{ period.id }} </a>
</li>
</ul>
I add/remove the 'show' class by using the following method:
toggleClass() {
this.isShown = !this.isShown;
}
The problem I have is that since there are multiple <li> elements, every time I click on any of them the 'show' class is added to all of them.
What I want to achieve is that the class 'show' is only added to the <li> element that was just clicked.
period.isShown = !period.isShown(passing period as an argument into toggleClass)