Class IgxCalendarComponent

Ignite UI for Angular Calendar - Documentation

The Ignite UI Calendar provides an easy way to display a calendar and allow users to select dates using single, multiple or range selection.

Example:

<igx-calendar selection="range"></igx-calendar>

Hierarchy

  • IgxCalendarComponent

Implements

  • OnInit
  • ControlValueAccessor

Properties

id

id: string = `igx-calendar-${NEXT_ID++}`

Sets/gets the id of the calendar. If not set, the id will have value "igx-calendar-0".

<igx-calendar id = "my-first-calendar"></igx-calendar>
let calendarId =  this.calendar.id;
memberof

IgxCalendarComponent

onSelection

onSelection: EventEmitter<Date | Date[]> = new EventEmitter<Date | Date[]>()

Emits an event when a selection is made in the calendar. Provides reference the selectedDates property in the IgxCalendarComponent.

<igx-calendar (onSelection) = "onSelection($event)"></igx-calendar>
memberof

IgxCalendarComponent

vertical

vertical: boolean = false

Sets/gets whether the calendar header will be in vertical position. Default value is false.

<igx-calendar [vertical] = "true"></igx-calendar>
let isVertical = this.calendar.vertical;

Accessors

activeView

context

  • get context(): object
  • Gets the context for the template marked with either igxCalendarSubHeaderMonth or igxCalendarSubHeaderYear directive.

    let context =  this.calendar.context;

    Returns object

disabledDates

formatOptions

  • get formatOptions(): object
  • set formatOptions(formatOptions: object): void
  • Gets the date format options of the calendar.

    let dateFormatOptions = this.calendar.formatOptions.

    Returns object

  • Sets the date format options of the calendar.

    <igx-calendar> [formatOptions] = "{ day: '2-digit', month: 'short', weekday: 'long', year: 'numeric' }"</igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    • formatOptions: object

    Returns void

formatViews

  • get formatViews(): object
  • set formatViews(formatViews: object): void
  • Gets whether the day, month and year should be rendered according to the locale and formatOptions, if any.

    let formatViews = this.calendar.formatViews;

    Returns object

  • Gets whether the day, month and year should be rendered according to the locale and formatOptions, if any.

    <igx-calendar [formatViews] = "{ day: true, month: false, year: true }"></igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    • formatViews: object

    Returns void

headerContext

  • get headerContext(): object
  • Gets the context for the template marked with the igxCalendarHeader directive.

    let headerContext =  this.calendar.headerContext;

    Returns object

headerTemplate

  • get headerTemplate(): any
  • set headerTemplate(directive: any): void
  • Gets the header template.

    let headerTemplate =  this.calendar.headerTeamplate;
    memberof

    IgxCalendarComponent

    Returns any

  • Sets the header template.

    <igx-calendar headerTemplateDirective = "igxCalendarHeader"></igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    • directive: any

    Returns void

isDecadeView

  • get isDecadeView(): boolean

isDefaultView

  • get isDefaultView(): boolean

isYearView

  • get isYearView(): boolean

locale

  • get locale(): string
  • set locale(value: string): void
  • Gets the locale of the calendar. Default value is "en".

    let locale =  this.calendar.locale;
    memberof

    IgxCalendarComponent

    Returns string

  • Sets the locale of the calendar. Expects a valid BCP 47 language tag. Default value is "en".

    <igx-calendar [locale] = "de"></igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    • value: string

    Returns void

selection

  • get selection(): string
  • set selection(value: string): void
  • Gets the selection type of the calendar. Default value is "single". Changing the type of selection in the calendar resets the currently selected values if any.

    let selectionType =  this.calendar.selection;
    memberof

    IgxCalendarComponent

    Returns string

  • Sets the selection type of the calendar.

    <igx-calendar [selection] = "'multi'"></igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    • value: string

    Returns void

specialDates

subheaderTemplate

  • get subheaderTemplate(): any
  • set subheaderTemplate(directive: any): void

value

  • get value(): Date | Date[]
  • set value(value: Date | Date[]): void
  • Gets the selected date(s) of the calendar.

    When the calendar selection is set to single, it returns a single Date object. Otherwise it is an array of Date objects.

    let selectedDates =  this.calendar.value;
    memberof

    IgxCalendarComponent

    Returns Date | Date[]

  • Sets the selected date(s) of the calendar.

    When the calendar selection is set to single, it accepts a single Date object. Otherwise it is an array of Date objects.

     this.calendar.value =  new Date(`2016-06-12`);
    memberof

    IgxCalendarComponent

    Parameters

    • value: Date | Date[]

    Returns void

viewDate

  • get viewDate(): Date
  • set viewDate(value: Date): void
  • Gets the date that is presented in the calendar. By default it is the current date.

    let date = this.calendar.viewDate;
    memberof

    IgxCalendarComponent

    Returns Date

  • Sets the date that will be presented in the default view when the calendar renders.

    <igx-calendar viewDate = "15/06/2018"></igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    • value: Date

    Returns void

weekStart

  • get weekStart(): WEEKDAYS | number
  • set weekStart(value: WEEKDAYS | number): void
  • Gets the start day of the week. Can return a numeric or an enum representation of the week day. Defaults to Sunday / 0.

    let weekStart =  this.calendar.weekStart;
    memberof

    IgxCalendarComponent

    Returns WEEKDAYS | number

  • Sets the start day of the week. Can be assigned to a numeric value or to WEEKDAYS enum value.

    <igx-calendar [weekStart] = "1"></igx-calendar>
    memberof

    IgxCalendarComponent

    Parameters

    Returns void

Methods

animationDone

  • animationDone(event: any, isLast: boolean): void

deselectDate

  • deselectDate(value?: Date | Date[]): void
  • Deselects date(s) (based on the selection type).

    this.calendar.deselectDate(new Date(`2018-06-12`));
    `

    Parameters

    • Optional value: Date | Date[]

    Returns void

selectDate

  • selectDate(value: Date | Date[]): void
  • Selects date(s) (based on the selection type).

    this.calendar.selectDate(new Date(`2018-06-12`));

    Parameters

    • value: Date | Date[]

    Returns void