Search code examples
angulartypescriptfullcalendarfullcalendar-schedulerfullcalendar-4

How to initialize Full Calendar version 4 in Angular


I'm trying to use the Full Calendar version 4 so I can use mouse over events on events in background mode. For some reason I cannot initialize it in my component(set options), I mean its working when I run ng serve, but I get error on my IDE. I will post the picture error here along with my code. Official docs you can see here https://fullcalendar.io/docs/v4/release-notes

I tried using OptionInputs as a parameter but that didn't work

  import { Component, OnInit } from '@angular/core';
  import { DataService } from './../../shared/services/data.service';
  import 'fullcalendar';
  import { Calendar } from 'fullcalendar';

  @Component({
  selector: 'app-calendar',
  templateUrl: './calendar.component.html',
  styleUrls: ['./calendar.component.css']
  })
 export class CalendarComponent implements OnInit {
 constructor(private dataService: DataService) {}

 myEvents = [];

 transformDate(str: String) {
   return str.substr(0, 10);
 }
  ngOnInit() {
const calendarEl = document.getElementById('calendar');

const calendar = new Calendar(calendarEl, {
  events: [
    {
      title: 'Test A',
      start: '2018-10-09T16:00:00'
    }
  ]
});

calendar.render();

} }

enter image description here


Solution

  • You are writing the options object in a wrong structure, it requires a plugin property

    const calendar = new Calendar(calendarEl, {
      events: [
        {
          title: 'Test A',
          start: '2018-10-09T16:00:00'
        }
      ],
       plugins: []
    });
    

    Stackblitz