I'm new to Angular and still trying to get into Angular thinking . I've several buttons like :
<button class="btn" (click)="btn1()" [ngClass]="test ? 'Style':'StyleChange'">btn1</button>
<button class="btn" (click)="btn2()" [ngClass]="test ? 'StyleChange':'Style'">btn2</button>
<button (click)="btn3()" [ngClass]="test? 'Style':'StyleChange'">btn3 </button>
And I'm trying to apply multiple classes through ngClass to have active class only on one button at time. I try to do it in this way but when i click third button ,first button gets the class too. I know that i can use ngFor and will be more easy to achive this but i need to work with every button later.
Component.ts code
test = true;
btn1(){
this.test = !this.test;
}
btn2(){
this.test = !this.test;
}
btn3(){
this.test=!this.test
}