angular date picker component navigator

DayPilot Editions

DayPilot Lite

The Navigator date picker component is included in @daypilot/daypilot-lite-angular package.

DayPilot Pro

The Navigator is included in DayPilot Pro for JavaScript.

Tutorials

Open-Source Tutorials

Pro Tutorials

Example

import {Component, ViewChild, AfterViewInit} from "@angular/core";

// DayPilot Lite
import { DayPilot, DayPilotNavigatorComponent } from "@daypilot/daypilot-lite-angular";

// DayPilot Pro
import { DayPilot, DayPilotNavigatorComponent } from "daypilot-pro-angular";

@Component({
  selector: 'date-picker-component',
  template: `
    <daypilot-navigator [config]="configNavigator" [events]="events" [(date)]="date" (dateChange)="changeDate($event)" #navigator></daypilot-navigator>
  `,
  styles: [``]
})
export class CalendarComponent implements AfterViewInit {

  @ViewChild("navigator") nav!: DayPilotNavigatorComponent;

  events: DayPilot.EventData[] = [];

  date = DayPilot.Date.today();

  configNavigator: DayPilot.NavigatorConfig = {
    showMonths: 3,
    cellWidth: 25,
    cellHeight: 25,
    onVisibleRangeChanged: args => {
      this.loadEvents();
    }
  };

  changeDate(date: DayPilot.Date): void {
    // handle date selection here
  }

  constructor(private ds: DataService) {
  }

  ngAfterViewInit(): void {
    this.loadEvents();
  }

  loadEvents(): void {
    const from = this.nav.control.visibleStart();
    const to = this.nav.control.visibleEnd();
    this.ds.getEvents(from, to).subscribe(result => {
      this.events = result;
    });
  }

}