Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

Datepicker selection off by one selection for display from ngModel with ng-model-options #3349

Closed
@tophallen

Description

@tophallen

So I have an issue with the datepicker popup when I have ng-model-options present on the element, I have been able to replicate in a plunker here and able to confirm that removing the ngModelOptions does indeed restore normal display of the actual active date.

What seems to be happening on a auto-closing datepicker is that the model is getting updated after the datepicker leaves scope, because of the way the mgModelOptions are delaying the model update until it is too late(the datepicker is closed already).

I think it is the default blur or the debounce I have provided, but I don't see any reason why I wouldn't be able to have them on there for when a user manually types a date in. I found that just wrapping the self.activeDate assignment like so: $timeout(function () { self.activeDate = date; }); in $scope.select function in the DatepickerController does seem to ensure that the displayed selection stays in sync on every change, since it is delaying the update of the active selection until the digest cycle that the model update is happening in, the demo shows it broken, but I included a version of the datepicker.js with the fix, so you can switch and confirm that it does fix it. But there are probably a couple of other options as well to ensuring that the displayed date gets properly updated.

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions