Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickers not selecting values when ngModelOption.updateOn is set on the input #186

Closed
coryvb123 opened this issue Mar 28, 2017 · 11 comments
Closed

Comments

@coryvb123
Copy link

coryvb123 commented Mar 28, 2017

When I add ng-model-options="{ updateOn: 'blur' }" to the input element, the datepicker and timepicker stop updating the input and model, and stop closing themselves.

It appears that $viewChangeListeners is not being triggered anymore and therefore dateSelection() is not being called by ng-change.

https://plnkr.co/edit/XF2mduZsuNsaSC7Q1Vgs?p=preview

@mahendra2125
Copy link

Hi, Do you have any update the above issue, i am also facing the same with the ng-model-options. It would be nice if you replay on this.

@Gillardo
Copy link
Owner

Sorry not been working on this library much lately. Looking at the code, it seems that you we could probably sort this by changing this line....

$scope.ngModelOptions = angular.copy(ngModelOptions);

if ($scope.ngModelOptions.updateOnDefault === true) {
	$scope.ngModelOptions.updateOn = $scope.ngModelOptions.updateOn ?
	$scope.ngModelOptions.updateOn + ' default' : 'default';
}

to

$scope.ngModelOptions = angular.copy(ngModelOptions);

$scope.ngModelOptions.updateOn = $scope.ngModelOptions.updateOn ?$scope.ngModelOptions.updateOn + ' default' : 'default';

This would fix the problem but would overwrite the updateOn blur option all together.

If you wanted to keep updateOn (which only applies to input fields), then we would need to create a separate copy of modelOptions for the datepicker which did not use the updateOn blur option, because a blur event never happens.

@mahendra2125
Copy link

Hi After done this modification now it is taking the ngmodeloptions on blur event but if we select the date form the date picker "ngModel.$viewChangeListeners.push(function () {" function to update the value to the model is not triggering. Can u plz check on this.

@Gillardo
Copy link
Owner

What about this?? https://plnkr.co/edit/OmxkChcPzluFNfu7py9s

Here i have updated the component slightly, and wonder if it helps you. If so, i can make these changes and put live.

@mahendra2125
Copy link

mahendra2125 commented Feb 20, 2018

Hi, Thank you for your quick help. Your code to manually trigger the blur event working fine.

Please push the changes so will pull and implement it.

Please let me know once you push the modified changes.

Gillardo added a commit that referenced this issue Feb 20, 2018
Fixed #186
@Gillardo
Copy link
Owner

New version published for you

@mahendra2125
Copy link

Hi,

I am getting below error in ipad, can you please help me with this.

Datepicker directive: "ng-model" value must be a Date object.

I am getting the date objects from the service and passing those values using new Date(value) and it is giving error

@Gillardo
Copy link
Owner

what format are your dates from the service?

@mahendra2125
Copy link

mahendra2125 commented Apr 17, 2018

I am parsing this format with new Date(2018-04-16 12:07:00).

I am getting this error only in safari.

Got the solution now it is working fine.
it is accepting the date format like (MM/dd/yyyy)

@Gillardo
Copy link
Owner

This may help you. #222

I am going to release new version with this fix shortly

@Gillardo
Copy link
Owner

@mahendra2125 2.6.2 is now released. Upgrade and this should fix your issue

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

No branches or pull requests

3 participants