Skip to content

defaultMonth attribute

Keke edited this page May 27, 2021 · 6 revisions

Selects specific month and year on calendar. When the calendar opens and the date is not selected the selection of the month is given month and the selection of the year is given year. In default (overrideSelection property is set to false) case if the date is already selected its selection overrides the value of the defaultMonth.

If overrideSelection property is set to true the calendar opens month/year specified in the defaultMonth even the date is selected.

Value of the defaultMonth attribute can be changed dynamically.

<input angular-mydatepicker [(ngModel)]="model" [options]="myDatePickerOptions" 
    #dp="angular-mydatepicker" [defaultMonth]="defaultMonth">
import {IAngularMyDpOptions, IMyDefaultMonth} from 'angular-mydatepicker';

export class MyApp {
    myDatePickerOptions: IAngularMyDpOptions = {
        // options here...
    }

    // set default month August of 2019
    defaultMonth: IMyDefaultMonth = {
        defMonth: '08/2019',
        overrideSelection: false
    };

    constructor() {}

    changeDefaultMonthDynamically(): void {
        this.defaultMonth = {
            defMonth: '09/2020',
            overrideSelection: true
        };
    }
}