我在我的angular 7应用程序中使用FullCalendar,我在日期上添加了多个事件,这些事件来自后端逻辑。我已经能够获得日期点击事件的日期,但是我似乎无法获得事件点击方法的日期。我一直在尝试获取完整日历中的活动日期。
假定日期已加载到fullcalendar的events属性上。
。html文件
<full-calendar dateClick="dateClick($event)" eventClick="eventClick($event)">
。ts文件
eventClick(model){
console.log(model);
}
但是这不会给我单击事件的日期。任何帮助,将不胜感激。
<full-calendar dateClick="dateClick($event)" (click)="eventClick($event)">
尝试使用单击括号
您需要将事件绑定到dateClick
。另外,您还需要导入交互插件。
import { Component } from "@angular/core";
import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin from '@fullcalendar/interaction';
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
name = "Angular";
calendarPlugins = [dayGridPlugin, interactionPlugin]; // important!
handleDateClick(arg) {
// handler method
alert(arg.dateStr);
}
}
<full-calendar (dateClick)="eventClick($event)" [plugins]="calendarPlugins">