import { OptionsInput } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
import { CalendarComponent } from 'ng-fullcalendar';
@Component({
selector: 'demo-app',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
options: OptionsInput;
eventsModel: any;
@ViewChild('fullcalendar') fullcalendar: CalendarComponent;
ngOnInit() {
this.options = {
editable: true,
events: [{
title: 'Long Event',
start: this.yearMonth + '-07',
end: this.yearMonth + '-10'
}],
customButtons: {
myCustomButton: {
text: 'custom!',
click: function() {
alert('clicked the custom button!');
}
}
},
header: {
left: 'prev,next today myCustomButton',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
plugins: [ dayGridPlugin, interactionPlugin ]
};
}
eventClick(model) {
console.log(model);
}
eventDragStop(model) {
console.log(model);
}
dateClick(model) {
console.log(model);
}
updateEvents() {
this.eventsModel = [{
title: 'Updaten Event',
start: this.yearMonth + '-08',
end: this.yearMonth + '-10'
}];
}
get yearMonth(): string {
const dateObj = new Date();
return dateObj.getUTCFullYear() + '-' + (dateObj.getUTCMonth() + 1);
}
}