我有以下EventInput
:
calendarEvents: EventInput[] = [
{
title: "Event Now - 1",
start: new Date().setHours(10)
},
{
title: "Event Now - 2",
start: new Date()
}
];
和在HTML中:
(eventClick)="selectedEvent($event)"
是否可以为每个EventInput
设置ID并通过selectedEvent
方法获取该ID,因为我想获取数据形式Api以基于Id的模式显示?
selectedEvent($event) {
// get Id in here ...
console.log($event.view);
}
Stackblitz Here ...
答案 0 :(得分:2)
尝试这样:
selectEvent($event) {
console.log($event.event.title);
}
您还可以在对象中设置id
属性,
calendarEvents: EventInput[] = [
{
id:1,
title: "Event Now - 1",
start: new Date().setHours(10)
},
{
id:2,
title: "Event Now - 2",
start: new Date()
}
];
并像这样获得id
:
selectEvent($event) {
console.log($event.event.id);
}