Trying to build a schedule set up tool in angular. I have ng-fullcalendar implemented and displaying as I want. When you click on a day it should show a div containing a simple form to fill out.
I'm getting the dayClick even and the date from it just fine, but when I try and use that in a 2-way binding or any other 2 way binding really nothing happens. Pretty sure it is a scope issue related to this, but I just can't figure it. Kinda new to angular still.
Anyway, here is code simplified a bit. The HTML:
<div *ngIf="scheduleCalendarOptions" class="calendarwraper">
<ng-fullcalendar #scheduleCalendar [options]="scheduleCalendarOptions"></ng-fullcalendar>
</div>
<div *ngIf="showScheduleModal === true" style="width: 450px; background-color: #ffffff; height: 500px; border: 1px solid #cccccc; position: absolute; top: 120px; z-index: 10; left: 50%; margin-left: -225px; ">
<p>{{dayClickDate}}</p>
</div>
The .ts
export class BoardComponent implements OnInit {
showScheduleModal: boolean = false;
dayClickDate: any = 'test';
this.scheduleCalendarOptions = {
dayClick: (date, jsEvent, view) => this.clickDay(date, jsEvent, view),
};
clickDay(date, jsEvent, view) {
const clickedDate = new Date(date).toLocaleString('en-US', {timeZone: 'UTC'}).split(', ');
console.log(clickedDate[0]);
this.showScheduleModal = true;
this.dayClickDate = clickedDate;
console.log('this.dayClickDate: ', this.dayClickDate);
}
}
The calendar shows up fine. The dayClick even fires and enters the clickDay method. The console.log(clickedDate[0]) works just fine. But showScheduleModal and dayClickDate are not being updated. If I manually show the hidden div the date isn't ever updated. I'm guessing the problem is the this in this.showScheduleModal and may have something to do with the arrow function? Any suggestions would be greatly appreciated! Thanks.
Update... I added another console.log at end of clickDay method and it outputs what I expect, the stored date. but the html template looking at dayClickDate isn't updating, even though the variable clearly holds the proper value. So confused.