Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Cancel resets to today's date #40

Closed
jmazin opened this issue Aug 15, 2014 · 1 comment
Closed

Cancel resets to today's date #40

jmazin opened this issue Aug 15, 2014 · 1 comment

Comments

@jmazin
Copy link

jmazin commented Aug 15, 2014

Hi! Thx for your work-- it's certainly appreciated. I've noticed that if you click 'cancel' the first time the picker loads, the dates will reset (in the picker) to today's date -- you can reproduce it in your demo to see what I mean. I'd like to help solve this issue but not sure how to go about it.

@jmazin jmazin closed this as completed Sep 15, 2014
@arcadeJHS
Copy link

Hi!
Maybe this issue is closed, but I run in the same problem!
I solved it modifying the code in the change watcher:

            $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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants