Within the component's export class, I have defined iconCheck: string;
. In the constructor, I set this.iconCheck = "add_circle";
. Additionally, in the export class, I have the following method:
iconChange() {
if(this.iconCheck == "add_circle") {
this.iconCheck = "remove_circle"
} else {
this.iconCheck = "add_circle";
}
}
My HTML contains multiple collapsible/expandable elements using Bootstrap accordions. Each element has a toggle icon (+/-) that should change when clicked. However, the issue is that when one accordion is clicked, all other accordions' icons also change. I am looking for a way to bind the click event to only the specific element that was clicked. Essentially, I need a scope limit or a way to isolate the click event to just the individual element that triggered it.
<a data-toggle="collapse" (click)="iconChange()" href="#collapse1">
Property 1
<i class="material-icons pull-right">{{iconCheck}}</i>
</a>
<a data-toggle="collapse" (click)="iconChange()" href="#collapse2">
Property 2
<i class="material-icons pull-right">{{iconCheck}}</i>
</a>