mominsamir / smDateTimeRangePicker

Angular Material Date Picker, DateTime Picker, Date Range Picker, Date Time range picker
http://mominsamir.github.io/smDateTimeRangePicker/
MIT License
130 stars 50 forks source link

on-range-select returns previous value, not current value #60

Open voidsteed opened 7 years ago

voidsteed commented 7 years ago

I'm using date range picker, with my own variable in controller, every time when I select a range and click save button, the call back function returns previous date range I picked when I'm using console.log to print in controller, but in UI views it shows the current date range I picked.

mominsamir commented 7 years ago

i am fixing other issues, i will check this as well and fix it

pablorsk commented 7 years ago

@voidsteed try update your repository. It's fixed now.

voidsteed commented 7 years ago

Thank you @pablorsk , I will check it out.

lashisu commented 7 years ago

This issue is still there. It comes when you choose mode="date". There is one more issue. When you chose "close-on-select", picker do not return in the correct format.

This is the plunker url for demo where I have produced the issue. Please & resolve this issue. http://plnkr.co/edit/P94pfjosot1gOxcwp1Ui?p=preview

wesleifreitas commented 7 years ago

@mominsamir It seems the problem is in calender-date.js (line:63 and 64)

       if(self.restrictToMinDate){
            if(moment.isMoment(self.minDate)){
                self.minDate = self.minDate.subtract(1, 'd'); // <- here
            }else{
                self.minDate = moment(self.minDate, self.format).subtract(1, 'd'); //<- and here
            }
        }

Changing to code below, the problem is fixed, but I do not know if it causes another problem, I did some tests it seems that everything is ok, what do you think? Can I send a pull request?

       if(self.restrictToMinDate){
            if(moment.isMoment(self.minDate)){
                self.minDate = self.minDate;
            }else{
                self.minDate = moment(self.minDate, self.format);
            }
        }
wesleifreitas commented 7 years ago

fixed #124

mailmrmanoj commented 7 years ago

+1