Reputation:
I have the following EventInput
:
calendarEvents: EventInput[] = [
{
title: "Event Now - 1",
start: new Date().setHours(10)
},
{
title: "Event Now - 2",
start: new Date()
}
];
and In HTML:
(eventClick)="selectedEvent($event)"
Is it possible to set Id for each EventInput
and get that Id in selectedEvent
method because I want to get data form Api to show in a modal based on the Id?
selectedEvent($event) {
// get Id in here ...
console.log($event.view);
}
Stackblitz Here ...
Upvotes: 0
Views: 464
Reputation: 22203
Try like this:
selectEvent($event) {
console.log($event.event.title);
}
You can also set id
property in the objects,
calendarEvents: EventInput[] = [
{
id:1,
title: "Event Now - 1",
start: new Date().setHours(10)
},
{
id:2,
title: "Event Now - 2",
start: new Date()
}
];
and get id
like this:
selectEvent($event) {
console.log($event.event.id);
}
Upvotes: 1