ng-bs-daterangepicker icon indicating copy to clipboard operation
ng-bs-daterangepicker copied to clipboard

model does not update when selecting current...

Open deifos opened this issue 10 years ago • 2 comments

... model does not seem to update if you select current date on both calendars, this only happens when you load the page after you select a different date and apply and then try to select current date on both calendars it seems to work just fine.

deifos avatar Dec 22 '14 15:12 deifos

If I understood write, then I have the same problem. Spets to reproduce:

  1. Insert in html
<input type="daterange" format="DD MMMM YYYY" locale="advSearchCtrl.locale" ng-model="createdRange">
  1. In controller
createdRange = {};
  1. Now open daterangepicker there are selected default value = today
  2. Click OK
  3. Model is not updating

The reson in this code of directive:

$element.daterangepicker(options, function(start, end, label) {
    var modelValue = ngModel.$viewValue;

    if (angular.equals(start, modelValue.startDate) && angular.equals(end, modelValue.endDate)) {
        return;
    }

    $scope.$apply(function() {
        ngModel.$setViewValue({
            startDate: (moment.isMoment(modelValue.startDate)) ? start : start.toDate(),
            endDate: (moment.isMoment(modelValue.endDate)) ? end : end.toDate()
        });
        ngModel.$render();
    });
});

Now let's see bootstrap-daterangepicker code:

...
// On init step
this.startDate = moment().startOf('day');
this.endDate = moment().endOf('day');
...
// And callback condition
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
    this.notify();
...

asborisov avatar Sep 23 '15 11:09 asborisov

Can somebode explane to dangrossman than we need such kind of changes?

asborisov avatar Sep 24 '15 00:09 asborisov