I have successfully resolved the issues you were facing. In order to display events when the month changes, it is necessary to store this information either in your service or component. You can also refer to the updated StackBiltz
in your app.component.ts file
weeks: Array<Array<{date: Date, hasEvent: boolean, eventTitle: string}>>;
getEvents() {
this.calendar.setDate(this.date);
console.log(this.calendar.getWeeks());
this.weeks = this.calendar.getWeeks().map(x => { return x.map(y => { return {date: y, hasEvent: false, eventTitle: ""} }) });
const from = this.calendar.getFrom();
const to = this.calendar.getTo();
}
openModalContent(weekIdx, day) {
const modalRef = this.modalService.open(ModalContentComponent);
modalRef.result.then((result) => {
day.hasEvent = true;
day.eventTitle = result;
console.log("result -> ", result);
}).catch((error) => {
console.error(error);
});
}
in your app.component.html file
<tbody>
<tr *ngFor="let week of weeks; let weekIdx = index">
<td *ngFor="let day of week" class="day-of-month" [ngClass] = "{'bg-primary': day.hasEvent}">
<div class="events">
<span class="day-number">{{ day.date | date:'d' }}</span>
<button (click)="openModalContent(weekIdx, day)" class="btn-add">Add event</button>
</div>
</td>
</tr>
</tbody>