Open arcadeJHS opened 9 years ago
Hi! As stated by issue #40, daterange reset to today date when I open it the first time and click on "cacel" button.
I solved it modifying the code in the change watcher this way:
$scope.$watch($attributes.ngModel, function (modelValue) { if (!modelValue || (!modelValue.startDate)) { ngModel.$setViewValue({ startDate: moment().startOf('day'), endDate: moment().startOf('day') }); return; } $element.data('daterangepicker').setStartDate(modelValue.startDate); $element.data('daterangepicker').setEndDate(modelValue.endDate); $element.data('daterangepicker').updateView(); $element.data('daterangepicker').updateCalendars(); $element.data('daterangepicker').updateInputText(); });
setStartDate and setEndDate in fact also replace the "old" stored value. Is it the right way? Maybe the change could be integrated in a new source version?
:+1:
Hi! As stated by issue #40, daterange reset to today date when I open it the first time and click on "cacel" button.
I solved it modifying the code in the change watcher this way:
setStartDate and setEndDate in fact also replace the "old" stored value. Is it the right way? Maybe the change could be integrated in a new source version?