Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

48 lines (39 sloc) 1.39 KB
import { Component, ViewChild } from '@angular/core';
import { FullCalendarComponent } from '@fullcalendar/angular';
import { EventInput } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGrigPlugin from '@fullcalendar/timegrid';
import interactionPlugin from '@fullcalendar/interaction'; // for dateClick
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
@ViewChild('calendar') calendarComponent: FullCalendarComponent; // the #calendar in the template
calendarVisible = true;
calendarPlugins = [dayGridPlugin, timeGrigPlugin, interactionPlugin];
calendarWeekends = true;
calendarEvents: EventInput[] = [
{ title: 'Event Now', start: new Date() }
];
toggleVisible() {
this.calendarVisible = !this.calendarVisible;
}
toggleWeekends() {
this.calendarWeekends = !this.calendarWeekends;
}
gotoPast() {
let calendarApi = this.calendarComponent.getApi();
calendarApi.gotoDate('2000-01-01'); // call a method on the Calendar object
}
handleDateClick(arg) {
if (confirm('Would you like to add an event to ' + arg.dateStr + ' ?')) {
this.calendarEvents = this.calendarEvents.concat({ // add new event data. must create new array
title: 'New Event',
start: arg.date,
allDay: arg.allDay
})
}
}
}
You can’t perform that action at this time.