Hi every one I have created stackblitz https://stackblitz.com/edit/angular-fnvhnn-giypgb?file=app%2Fexpansion-overview-example.html for reference, I have used expansion panel to exapand the content, based on click the element the expansion happening in the stackblitz, for example if we click All element on top the all content will gets exapand, if we click B element the B content will gets expand.
What I exactly looking is I want to use ngstyle or ngclass in top loop of {{tab}}, if we click All tag it should be change into green color and again if click same All tag it's should change into red color, if we click B tag it should be change into green color again if click same B tag it's should change into red color like toggle.
if panelstate = false the tag should be in red color and if it is true it's need to change green color
panel open state:-
panelOpenState = false;
Top ngfor loop;-
<div style="display: flex;justify-content: space-evenly;">
<div *ngFor="let tab of getTablist();"> <p (click)='clickOntab(tab)' [ngStyle]="{'color':panelOpenState === 'true' ? 'green' : 'red' }">{{tab}}</p></div>
</div>
Ts File
panelOpenState = false;
public tabType: string = "";
clickOntab(tab) {
if (this.tabType != "" && this.tabType === tab) {
this.panelOpenState = false;
this.tabType = "";
} else {
this.panelOpenState = true;
this.tabType = tab;
}
}
getTablist() {
const tabList = this.cricketList.map(list => list.alphabet);
return ["All"].concat(tabList);
}
}