Angular-calendar: Using custom event properties in CalendarEventTimesChangedEvent

Created on 6 Apr 2017  路  1Comment  路  Source: mattlewis92/angular-calendar

Bug description / Feature request:

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.

Versions

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

Most helpful comment

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");
            }
      }
}

>All comments

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");
            }
      }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

agilob picture agilob  路  3Comments

Sushma-tiwari picture Sushma-tiwari  路  3Comments

AstRonin picture AstRonin  路  4Comments

Herb-sh picture Herb-sh  路  4Comments

Seb69 picture Seb69  路  3Comments