【发布时间】:2019-01-18 15:44:57
【问题描述】:
我正在使用p-fullCalendar 控件来显示约会。
我想在标题中添加一个自定义按钮来添加新约会。
我已经通过在选项as per full calendar docs 中指定它来做到这一点:
export class AppointmentsComponent implements OnInit {
events: any[];
options: any;
displayAddAppointment: boolean;
constructor() { }
ngOnInit() {
this.options = {
header: {
left: 'prev,next today',
center: 'title',
right: 'addAppointmentButton, month,agendaWeek,agendaDay'
},
customButtons: {
addAppointmentButton:{
text:"New appointment",
click: r=> {
//this works but displayAddAppointment within the component is inaccessible.
//I would like to display a modal dialog to add a new appointment from this.
}
}
}
};
html 是:
<div>
<p-fullCalendar [events]="events" [options]="options"></p-fullCalendar>
<p-dialog header="Schedule new appointment"
[(visible)]="displayAddAppointment"
modal="modal">
</p-dialog>
<div>
按钮显示正常,点击事件也被触发。
但是如何处理这个按钮的点击事件,以便显示模态对话框呢?
点击事件中的this 是按钮本身:
【问题讨论】:
-
点击事件中
this指的是什么? -
@MarkusDresch 我已更新问题以回答您的问题
标签: angular primeng primeng-calendar