Is there a way to assign different classes to buttons generated using *ngFor without changing the class for all previously created buttons when toggled? I have 2 search bars adding text to the same array, displayed as buttons. I want to differentiate between data from searchbar1 in blue and searchbar2 in orange, while maintaining the order of selection.
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 triggered when clicking on search bar results.