i've added @fullcalendar/angular in my angular application but my [events] doesn't work.
in my app.module.ts:
FullCalendarModule.registerPlugins([
dayGridPlugin,
interactionPlugin,
timeGridPlugin
])
imports: [
...
...
FullCalendarModule
]
//.ts file
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import { CalendarOptions, FullCalendarComponent } from '@fullcalendar/angular';
import { EventInput } from '@fullcalendar/core';
import interactionPlugin from '@fullcalendar/interaction';
import { title } from 'process';
import { event } from '../common/models/event';
@Component({
selector: 'app-my-profile',
templateUrl: './my-profile.component.html',
styleUrls: ['./my-profile.component.css']
})
export class MyProfileComponent implements OnInit {
posts =[];
//full calendar specified , static : true is obligatory
@ViewChild("fullcalendar", { static: true })
calendarComponent: FullCalendarComponent;
ngOnInit(): void {
this.service.getEvents(this.username).subscribe(
(data) => {
for(let i = 0; i <= Object.keys(data).length; i++){
const e = new event;
if(data[i]!=undefined){
e.setTitle(data[i].title);
e.setStart(data[i].start);
e.setEnd(data[i].end);
e.setColor(data[i].color);
this.posts.push(e);
}
}
console.log(" my events " + JSON.stringify(this.posts));
}
)
}
}
in my .html file
<full-calendar #fullcalendar [events]="posts" defaultView="dayGridDay" [options]="calendarOptions" ></full-calendar>
i have this error Can't bind to 'events' since it isn't a known property of 'full-calendar'.
i also tried an other solution to set myEvents fetched from database to calendarOptions but it doesn't work.
calendarOptions: CalendarOptions = {
initialView: 'timeGridWeek',
dateClick: this.handleDateClick.bind(this), // bind is important!
locale: 'fr',
events: this.posts
}