g00fy- / angular-datepicker

calendar and datepicker directives for angular
MIT License
719 stars 420 forks source link

Datepicker with an empty ng-model #295

Open aurenda opened 8 years ago

aurenda commented 8 years ago

Cannot have a datepicker with an empty ng-model because it shows invalid date or the current date. I think it would be a good idea to have an option to specify if I want to have a value when the model is initialized (with the current date) or an empty object (or string). There are some cases (such as having a form where the input field related to the datepicker is not required) when it is not necessary to select a date; it is confusing then that the current date appears always in the input field. I made a workaround for this and modified the code below sending an empty string in the function "formatter". This is only a workaround but I think a functionality like this will add value to your component.

function formatter(value) { return value != "" ? dateFilter(value, format, timezone) : ""; }

cipchk commented 8 years ago

199

Dr1Ku commented 8 years ago

Would be fixed by PR https://github.com/g00fy-/angular-datepicker/pull/293