-
Notifications
You must be signed in to change notification settings - Fork 26
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
ui datepicker and resetModel() #79
Comments
Sorry, I don't have a lot of time to look into this. I recommend you ask on the chat: http://chat.angular-formly.com |
@kentcdodds I bet you don't! (belated congratulations by the way :) ) I've asked the chat room. Thanks. |
Hi @kentcdodds Can I ask why this has been closed? Anyone coming across this, with the same issue, is going to feel that it's been fixed in an update, or they're doing something wrong. I appreciate that you're too busy to look at it at the moment, but the issue still remains. |
Quick fix from me. Might help someone, but I'm painfully aware that 'datepicker' is hardcoded into the resetModel() function, so it's not at a state to be thinking about pull requests. It get's me over the line at work for the time being. I've edited the resetModel() function to now check if the type is 'datepicker', and I do this: function resetModel() {
if ($scope.options.type === 'datepicker') {
var format = $scope.to.datepickerOptions && $scope.to.datepickerOptions.format || 'shortDate';
$scope.model[$scope.options.key] = $filter('date')($scope.options.initialValue, format);
} else {
$scope.model[$scope.options.key] = $scope.options.initialValue;
}
// Rest of the function...
} |
Ig this should be closed, now it's triggered the |
There is an issue with using the ui datepicker (and date formats / json) in formly when calling resetModel().
As you can see here, resetModel() actually removes the model for that element. This is the same when using a pre-populated model, or the 'defaultValue' property:
http://jsbin.com/vokowo/edit?html,js,output
Hitting resetModel twice actually fixes the problem - it returns the values to the model. But, of course, this isn't satisfactory as is.
Any ideas?
The text was updated successfully, but these errors were encountered: