I am looking to implement the mobiscroll event for the calendar object (onMonthLoaded) in a way that allows me to have the logic outside of the settings element of mobiscroll.
Here is an example of my code:
export class CalendarComponent {
constructor( private sessionService: SessionService,
private visItemsService: VisibleItemsService,
) {
this.visItemsService.visItems$.subscribe(items => {console.log("got these New visible items : ", items)});
}
calendar: Date = new Date();
calendarSettings: any = {
theme: 'timelord',
display: 'inline',
layout: 'liquid',
controls: ['calendar'],
cssClass: 'tl-cal',
max: new Date(2030,12,31),
min: new Date(2005,1,1),
onDayChange: function (event,inst) {
// event.date returns the selected date in date format
// console.log('date '+event.date);
},
onMonthChange(event,inst) {
// console.log('changed');
// console.log(event.year);
// console.log(event.month); // 0-11
},
onMonthLoaded(event,inst) {
console.log('lloaded');
// console.log(event.year);
// console.log(event.month); // 0-11
// console.log('month :'+inst.getVal());
// This is where I want to call the loadNewVisItems method
//loadNewVisItems(year, month);
}
};
loadNewVisItems(year: number,month:number) {
console.log('in load New!');
let timeRangeStart = moment().year(year).month(month).date(1).hour(0).minutes(0).second(0);
let timeRangeEnd = timeRangeStart.add(1,'month').subtract(1,'second');
this.visItemsService.setTimeRange(timeRangeStart.unix(),timeRangeEnd.unix());
}
}
I am trying to figure out how to properly call the loadNewVisItems method from within the onMonthLoaded handler. The syntax currently does not recognize the method when I attempt a simple call using either this or another approach.