我是在我的fullCalendar 7应用程序中实现的,日历正在工作,我正在向它导入一些事件,但我试图更有效地完成它,我试图带来日历所需的事件。
所以..。我有些问题要问。
如何在Prev或Next或can按钮中获得单击事件?
我怎样才能得到现在的日期?
我一直在查文件..。但是只有jquery的例子。
在这里我复制我的HTML
<full-calendar id="calendar" *ngIf="options" #fullcalendar [editable]="true" [events]="citas"
[header]="options.header" [locale]="options.locale" [customButtons]="options.customButtons"
(dateClick)="dateClick($event)" [plugins]="options.plugins" (eventClick)="eventClick($event)" [eventLimit]="4">
</full-calendar>
和我的Ts
@ViewChild('fullcalendar') fullcalendar: FullCalendarComponent;
constructor() {
this.options = {
editable: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth, listDay'
},
plugins: [dayGridPlugin, listPlugin, timeGridPlugin],
locale: esLocale,
};
}
发布于 2019-07-11 17:31:37
根据插件的文档,您可以访问原始数据和方法的底层Calendar
对象:
const calendarApi = this.calendarComponent.getApi();
用于日期导航的方法的完整列表可以在这里找到:https://fullcalendar.io/docs/date-navigation。
因此,要获得我们可以使用的当前日期:calendarApi.getDate();
。
以下代码应该有效:
export class AppComponent {
// references the #calendar in the template
@ViewChild('calendar') calendarComponent: FullCalendarComponent;
someMethod() {
const calendarApi = this.calendarComponent.getApi();
const currentDate = calendarApi.getDate();
console.log("The current date of the calendar is " + currentDate);
}
}
我还没有发现针对prev和next按钮发出的任何事件,但是您可以使用calendar.prev()
和calendar.next()
方法构建自己的按钮。
goPrev() {
const calendarApi = this.calendarComponent.getApi();
calendarApi.next(); // call a method on the Calendar object
}
发布于 2021-06-02 10:34:26
现在我迟到了,但我想使用您的解决方案,因此:在calendarOptions中,您可以添加customButtons属性,然后将newNextFunct添加到fullCalendar函数中,如下所示:
customButtons: {
next: {
click: this.nextMonth.bind(this),
},
prev: {
click: this.prevMonth.bind(this),
},
today: {
text: "Aujourd'hui",
click: this.currentMonth.bind(this),
},
},
您的newNextFunction名为nextMonth,必须如下所示:
nextMonth(): void {
console.warn('nextMonth');
this.calendarApi = this.calendarComponent.getApi();
this.calendarApi.next();
}
https://stackoverflow.com/questions/56994088
复制相似问题