kekeh / angular-mydatepicker

Angular datepicker and date range picker :date:
https://kekeh.github.io/angular-mydatepicker/
MIT License
1 stars 11 forks source link

defaultMonth attribute not working #55

Closed JanakiKandukuri closed 4 years ago

JanakiKandukuri commented 4 years ago

I am using "angular-mydatepicker": "^0.9.12" version. I have a pre selected date, but when i open calendar i would like to see today Date. I saw your notes on using defaultMonth which overrides selected date. But it doesn't work as expected. It doesn't override with defaultMonth.

kekeh commented 4 years ago

Hi @JanakiKandukuri

It works so that the selected date overides to the default month.

<input angular-mydatepicker name="mydate"  [(ngModel)]="model" [options]="myDatePickerOptions" 
    [defaultMonth]="defMonth" #dp="angular-mydatepicker" autocomplete="off"/>
defMonth: IMyDefaultMonth = {
    defMonth: '2021/08'
};

Now if you open calendar and if the date is not selected the calendar visible month is August of 2021 because the default month. Then select the date 14/06/2020 (today). Again open the calendar and the calendar visible month is now July of 2020 because the selected date is 14/06/2020.

If the date is not selected and the default month is not set the calendar visible month is current month.

I think it works like expected.

JanakiKandukuri commented 4 years ago

Hi @kekeh

I thought default month overrides selected date. Is there a way we can do that? So in my application there are start and end dates. A start date can be as old as 2010. Now when i click on start date calendar i would like to see current month and date with selected date in the text box ?

kekeh commented 4 years ago

Can you use date range mode of this component? With date range mode you can select both the start date and the end date without closing the calendar after selection of start date.

Try date range picker here. Select Date range picker check box and after that select range from the calendar.

I will investicate new option. It would work so that default month will override the selected date if the value of the option would be true.

kekeh commented 4 years ago

I made a fix. Now you can override the date selection by the value of defaultMonth. You can use overrideSelection property of defaultMonth.

defaultMonth: IMyDefaultMonth = {
     defMonth: '08/2010',
     overrideSelection: true
};

Documentation: https://github.com/kekeh/angular-mydatepicker#defaultmonth-attribute Example: https://github.com/kekeh/angular-mydatepicker/wiki/defaultMonth-attribute

At first install version 0.10.0 from npm.

JanakiKandukuri commented 4 years ago

Thank you