I am currently developing an appointment booking application that showcases time slots for appointments by utilizing the *ngFor loop.
html
<div *ngFor="let item of allTimeSlots">
<div class="col-sm-3">
<div class="choice" data-toggle="wizard-slot" [attr.disabled]="item.status" (click)="slotSelected($event)">
<input type="radio" name="slot" value="{{item.timeSlot}}">
<span class="icon">{{item.timeSlot}}</span> {{item.status}}
</div>
</div>
</div>
typescript
for (var index = 0; index < this.totalMinutes; index += 15, i++) {
this.allTimeSlots[i] = new allTimeSlots("", false);
this.allTimeSlots[i].timeSlot = (hour <= 12 ? hour : hour - 12) + ":" + (minute <= 9 ? ("0" + minute) : minute) + " " + ampm;
this.bookedTimeSlots.forEach(element => {
if (this.allTimeSlots[i].timeSlot == element) {
this.allTimeSlots[i].status = true;
}
});
}
Attached is a screenshot illustrating time slots, where 'true' indicates a booked slot and 'false' indicates availability for debugging purposes. https://i.sstatic.net/iGjrd.png
Although my code runs without errors, all div
elements generated by *ngFor appear disabled. I attempted using *ngIf instead of disabled, which resolved the issue. However, I aim to show the availability status of time slots.