ng-bs-daterangepicker
ng-bs-daterangepicker copied to clipboard
model does not update when selecting current...
... 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.
If I understood write, then I have the same problem. Spets to reproduce:
- Insert in html
<input type="daterange" format="DD MMMM YYYY" locale="advSearchCtrl.locale" ng-model="createdRange">
- In controller
createdRange = {};
- Now open daterangepicker there are selected default value = today
- Click OK
- 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();
...
Can somebode explane to dangrossman than we need such kind of changes?