I have rendered buttons inside a list. I would like to change their color when i click on them. But when I click it changes the color for all the buttons in that list. But I only want to change the single button icon.
This my html
<li *ngFor="let datum of filteredData; let i = index">
<button mat-mini-fab (click)="onLike(datum);onToggle()" [style.background-color]="toggle ? 'green' : 'red'">
<mat-icon svgIcon="check" aria-hidden="false" aria-label="Example thumbs up SVG icon"></mat-icon>
</button>
</li>
And here is my ts logic
toggle=true;
onToggle() {
this.toggle = !this.toggle;
}
Any help would be appreciated!