fragaria / angular-daterangepicker

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

Starting with a null model, can't choose "Today" #86

Closed kijanawoodard closed 5 years ago

kijanawoodard commented 9 years ago

The problem we're seeing is that if the user clears the date manually, the control still thinks the previous date is still selected and won't let you select it again.

In the simple case, if the model is set to null, you can't pick "today" because it's already selected in the control.

belerweb commented 9 years ago

I got the same issue. +1

atardadi commented 9 years ago

+1

Wlada commented 8 years ago

+1

Does someone have some workaround? If not I will try to spend some time on this.

Thanks

asabirov commented 8 years ago

+1

jgolebiewski commented 8 years ago

+1

Till86 commented 8 years ago

+1 anyone made progress on the issue?

Till86 commented 8 years ago

Guess it was related to moment.js setting date to now, when invalid value was entered. should be fixed now (moment.js 2.11.0), so maybe there is a way to fix this issue, too.

drelei commented 8 years ago

I used "moment().toISOString()" for the value as a workaround.

cgatesman commented 5 years ago

FWIW, as a workaround, I added the following code into angular-daterangepicker in _init() after creating the daterangepicker:

el.on('apply.daterangepicker', function() {
  if(opts.singleDatePicker) {
    if($scope.model == null) {
      return $scope.$apply(function() {
        return $scope.model = moment().startOf('day');
      });
    }
  } else if(angular.isObject($scope.model) && $scope.model.startDate == null && $scope.model.endDate == null) {
    return $scope.$apply(function() {
      return $scope.model = {
        startDate: moment().startOf('day'),
        endDate: moment().endOf('day')
      };
    });
  }
});
cgatesman commented 5 years ago

Curious...why was this issue closed? Was this fixed in 3.0? I couldn't find a merged PR referencing this issue.