Overview

  • The Angular date picker component supports a free-hand range selection.

  • Use drag and drop to select a custom set of days to be displayed by the Calendar.

  • The free-hand range selection can be combined with the standard selection modes: day, week, month

License

Apache License 2.0

Angular Date Picker Component

angular date picker component open source

The open-source DayPilot Lite includes an Angular date picker component (DayPilot Navigator) which lets you select a specified date that will be displayed by the main calendar component.

Features:

Date Picker Selection Modes

The date picker component supports the following modes:

  • Day

  • Week

  • Month

Day Mode

angular date picker day select mode

Week Mode

angular date picker week select mode

Month Mode

angular date picker month select mode

By default, it uses the “Day” mode which selects the day that was clicked.

Free-Hand Mode with Drag and Drop Range Selection

angular date picker free hand range selection

The Navigator date picker component lets you select a custom date range.

In order to activate this option, use freeHandSelectionEnabled property:

configNavigator: DayPilot.NavigatorConfig = {
  // ...
  freeHandSelectionEnabled: true,
}

This mode can be combined with any standard selection mode (Day, Week, Month). Clicking a day will select the range specified by the selection mode. In addition to clicks, the date picker also supports selecting a date range using drag and drop.

configNavigator: DayPilot.NavigatorConfig = {
  // ...
  selectMode: "Week",
  freeHandSelectionEnabled: true,
}

How to Handle the Selection Change

You can use onTimeRangeSelected event handler to detect a change of the date range selection.

configNavigator: DayPilot.NavigatorConfig = {

  // ...

  onTimeRangeSelected: args => {
    console.log("args", args);
  }

  // ...

}

The args object holds information about the updated date selection:

  • args.start - start date/time

  • args.end - end date/time (end of the last selected day)

  • args.days - number of selected days

How to Update the Calendar View

The Angular Calendar component can display a custom number of days using the viewType: "Days" mode.

We will use this mode to display the date range selected using the free-hand date picker mode:

configNavigator: DayPilot.NavigatorConfig = {

  // ...

  onTimeRangeSelected: args => {
    this.configCalendar.viewType = "Days";
    this.configCalendar.startDate = args.start;
    this.configCalendar.days = args.days;
  }

  // ...

}