I'm trying to have different classes to my buttons that are generated using the *ngFor. But once I toggle the class it would change the class for all previously created buttons, which I know is logical but I hope that there could be a way.
*more context: I have 2 search bars, both adding their text into the same array. the the content of the array is displayed in buttons. I want to differentiate between incoming data, so text from searchbar1 in blue and searchbar2 in orange, while keeping the order of selection, which is why I didn't separate them into 2 buttons.
newAction(text){
this.classvalue = true;
this.ConvMsgs.push("ChatBot: "+text);
console.log(text);
}
newIntent(text){
this.classvalue =false;
this.ConvMsgs.push("User: "+text);
console.log(text);
}
.msg_cotainer{
margin-top: auto;
margin-bottom: auto;
margin-left: 10px;
border-radius: 25px;
background-color: #39adc7;
padding: 10px;
position: relative;
}
.msg_cotainer2{
margin-top: auto;
margin-bottom: auto;
margin-left: 10px;
border-radius: 0px;
background-color: chocolate;
padding: 10px;
position: relative;
}
<ng-container *ngFor="let button of ConvMsgs">
<br />
<button [ngClass]="classvalue? 'msg_cotainer':'msg_cotainer2'">{{button}}</button>
<br />
</ng-container>
these functions are called upon clicking on results from the search bars.