I am using Angular and Full Calendar. Is there any way to change to only enable list mode when the width of the screen is small?
HTML (This is where the config is used):
<div class="calendar-container">
<angular2-fullcalendar #calendar [options]="calendarOptions" (initialized)="onCalendarInit($event)"></angular2-fullcalendar>
</div>
TS (This is where data to show is set along with setting the initial config in the ngOnInit):
calendarOptions: any;
ngOnInit() {
this.innerWidth = window.innerWidth;
//Set general calendar options
this.calendarOptions = {
//defaultView: 'listMonth'
height:500,
editable: true,
eventLimit: false,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth'
},
eventClick: (calEvent, jsEvent, view) => {
//Open the dialog with event info
this.openDialog(calEvent);
}
}
}
onCalendarInit(e:boolean) {
if(e) {
this.subjectEventsService.subscribeToDataServiceGetSubjectEvents().subscribe(data=>{
this.ucCalendar.fullCalendar('removeEvents');
this.ucCalendar.fullCalendar('addEventSource', data);
this.eventsList = data;
});
}
}
Note the defaultView
option in the config, which when set to listMonth
, will by default show the listMonth
view which is the desired view when the screen is small. Along with this, I can remove the options to view other modes other than list in the header
object.
However, I am not sure how to get the angular2-fullcalendar
to update the config when the window is resized. I have tried to implement answers such as link, but to no avail. I have also tried to do something like:
<div class="calendar-container">
<angular2-fullcalendar #calendar [options]="window.innerWidth > 768 ? calendarOptions : calendarOptionsSmall" (initialized)="onCalendarInit($event)"></angular2-fullcalendar>
</div>
Where calendarOptionsSmall
is another config object with the desired config for a small screen, but, to no avail.
Can anyone help? Thanks.