我正在通过事件将数据注入车把日历页面,如控制器所示
router.get('/', function(req, res, next) {
Event.find().then((events) => {
console.log(events);
res.render('calendar', { title: 'Calendar', calendarlink: true, event: events });
}, (err) => {
res.status(400).send(err);
})
});
数据显示在控制台日志中,但我无法在calendar.hbs上显示 这是日历hbs的代码
$('#calendar').fullCalendar({
header: {
left: 'title',
center: 'agendaDay,agendaWeek,month',
right: 'prev,next today'
},
firstDay: 1, // 1(Monday) this can be changed to 0(Sunday) for the USA system
defaultView: 'month',
themeSystem: 'bootstrap3',
events: {{event}},
eventRender: function(event, element) {
element.find('.fc-title').append("<br/> " + event.description);
$(element).tooltip({
title: "Description: " + event.description
});
}
})
事件选项与呈现的JSON类似:
events: {
_id: 5a0757fa94aad82784cbf8a1,
title: 'SampleEvent',
start: 2017-11-11T22:34:00.000Z,
end: 2017-11-15T07:00:00.000Z,
address: 'Paris HQ, LA',
description: 'Get ready to live a moment of your lifetime',
__v: 0
},
{
_id: 5a0761055876ab10dc00a71f,
title: 'NewEvent',
start: 2017-11-06T08:00:00.000Z,
end: 2017-11-06T15:00:00.000Z,
address: 'digital hub',
description: 'All are invited',
__v: 0
},