I have a collection of buttons that, upon being clicked, should have a class added to change their color. Before adding the class to the clicked button, I want to ensure that any previously selected button has the class removed.
CSS
.selected-date-item {
background:#272829;
color:white;
}
HTML
<button class="date-time-select" *ngFor="let chooseDate of possibleDates" (tap)="selectPickupDate(chooseDate)">{{chooseDate}}</button>
JavaScript
updateSelectedDate(selectedDate) {
this.selectedDate = selectedDate;
}
https://i.sstatic.net/lczIi.png => https://i.sstatic.net/t60q4.png