I wanted to use my custom event property in the eventTimesChanged method but since the method uses the predefined CalendarEventTimesChangedEvent I can not access those properties.
For example:
interface TimeSlotEvent extends CalendarEvent {
id: number;
}
eventTimesChanged({ event, newStart, newEnd }: CalendarEventTimesChangedEvent): void {
for (let currEvent of this.events) {
if(event.id == currEvent.id){ // error, id is not known property of event
console.log("found same event");
}
}
}
event does not have a property id. I wanted to check if the timeslot was already taken by another event. I need to exclude the past event by checking the id. (the eventarray contains the old event time while the triggered eventparam does contain the new values. so the slot is "already" taken by the old event if it is slightly moved and long.
Angular:
"@angular/common": "^2.3.1",
Calendar library:
"angular-calendar": "^0.7.2",
Edit: I used a different solution for my problem (didn't realize that eventparam is the old event data.) Still would be cool to use custom event properties everywhere
You should be able to extend the interface in the same way e.g.
CalendarEventTimesChangedTimeSlotEvent extends CalendarEventTimesChangedEvent {
event: CalendarEvent;
}
or as there are only 3 properties just don't use the interface:
eventTimesChanged({ event, newStart, newEnd }: {event: TimeSlotEvent, newStart: Date, newEnd: Date}): void {
for (let currEvent of this.events) {
if(event.id == currEvent.id){
console.log("found same event");
}
}
}
or failing that you can just use typescripts "escape hatch" way of accessing properties with the [] notation:
eventTimesChanged({ event, newStart, newEnd }: CalendarEventTimesChangedEvent): void {
for (let currEvent of this.events) {
if(event['id']== currEvent.id) {
console.log("found same event");
}
}
}
Most helpful comment
You should be able to extend the interface in the same way e.g.
or as there are only 3 properties just don't use the interface:
or failing that you can just use typescripts "escape hatch" way of accessing properties with the
[]notation: