fragaria / angular-daterangepicker

Angular.js wrapper for dangrossman/bootstrap-daterangepicker
MIT License
519 stars 372 forks source link

range for today not working, with analysis #220

Closed mirabilos closed 5 years ago

mirabilos commented 7 years ago

Bootstrap Daterangepicker sets the default startDate and endDate to today’s start and end, making this…

 var thisMoment = moment();
[…]
    ranges: {
        'today': [moment(thisMoment).startOf('day'), moment(thisMoment).endOf('day')],

… not work (i.e. if you click on the “today” range, the field stays empty and the form not validated) because Bootstrap Daterangepicker only calls the Angular Daterangepicker-provided callback if the values actually change, nevermind that Angular Daterangepicker did not set any default values.

My current workaround is to set…

    startDate: moment(thisMoment),
    endDate: moment(thisMoment),

… in the configuration, but that’s of course not generically correct.

maust commented 7 years ago

I am running into the same issue without finding a workaround as I need:

So if a user clicks on 'today' after the dates were null nothing happens the input field gets populated but the model which is bound to the daterangepicker does not get set.

If somebody found a workaround please let me know.

maust commented 7 years ago

There is a PR which solves it. Would be nice if it gets merged. https://github.com/fragaria/angular-daterangepicker/pull/177/commits/f44980bb171e6b28051235c6fd67e1da135da536