0

I am creating events for the calendar using https://mattlewis92.github.io/angular-calendar/#/kitchen-sink.

As per the documentation events are created like below :

events: CalendarEvent[] = [
    {
      start: subDays(startOfDay(new Date()), 1),
      end: addDays(new Date(), 1),
      title: 'A 3 day event',
      color: colors.red,
      actions: this.actions,
      allDay: true,
      resizable: {
        beforeStart: true,
        afterEnd: true
      },
      draggable: true
    },
    {
      start: startOfDay(new Date()),
      title: 'An event with no end date',
      color: colors.yellow,
      actions: this.actions
    },
    {
      start: subDays(endOfMonth(new Date()), 3),
      end: addDays(endOfMonth(new Date()), 3),
      title: 'A long event that spans 2 months',
      color: colors.blue,
      allDay: true
    },

Here how to create events only for weekdays? (example Mon to Friday).In the CalendarEvent[], I don't have the option to exclude the weekends.

ramya k
  • 1
  • 2
  • I fixed the problem.Using the [cellTemplate]="customCellTemplate" we can control events on weekends. – ramya k Mar 19 '20 at 00:48

1 Answers1

0

<ng-template #customCellTemplate let-day="day" let-locale="locale">
  <div class="cal-cell-top">
    <span class="cal-day-badge" *ngIf="day.badgeTotal > 0"
      >{{ day.badgeTotal }}</span
    >
    <span class="cal-day-number"
      >{{ day.date | calendarDate:'monthViewDayNumber':locale }}</span
    >
  </div>
  **<small style="margin: 5px"
    >There are {{ day.events.length }} events on this day</small
  >**
</ng-template>

this custom template day property has a values 0,1,2,3,4,5,6 for all 7 days of the week. Using this we can control the event for the weekend.

code :

<div *ngIf="day.day!=0 && day.day!=6">
  <small class="cal-event cal-month-veiw"></small>

</div>
ramya k
  • 1
  • 2