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

Datepicker: "...ng-model" value must be..." on Clear action #3617

Closed
fifonik opened this issue May 5, 2015 · 10 comments
Closed

Datepicker: "...ng-model" value must be..." on Clear action #3617

fifonik opened this issue May 5, 2015 · 10 comments

Comments

@fifonik
Copy link

fifonik commented May 5, 2015

  1. Open http://angular-ui.github.io/bootstrap/
  2. Ctrl+Datepicker
  3. Open popup datepicker
  4. Choose any date
  5. Open popup datepicker again
  6. Click 'Clear' button
    =>
    In console you'll see error "Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date."

I have not expected any errors on clearing date (setting it to null).
At least in 0.12.1 I had not have any errors.

@Grottkjell
Copy link

Having the same issue. Using angular 1.3.15.

@ghost
Copy link

ghost commented May 15, 2015

I have this problem too and have had to downgrade to an older version to support nullable dates. Any other workaround?

@DieterLi
Copy link

Same issue with 0.13.0, but good with 0.12.1

@anilnatha
Copy link

I am running Angular 1.3.16, and Angular UI-Bootstrap 0.13.0, and get the same error message upon clicking 'clear' in the datepicker modal as the OP does.

What makes it worse is that I am checking my forms $invalid property which is returning true even though the datepicker field in my form is not a required field, so a blank datepicker field should be valid, not invalid.

Also worth mentioning that if you open up Firebug while viewing the DatePicker demo at https://angular-ui.github.io/bootstrap/, it throws the error as noted by the OP.

@anilnatha
Copy link

I have created a plunker, with documentation that describes the various problems related to this bug:

http://plnkr.co/edit/Iild15cgR9NXaX0iWjti?p=preview

This example aims to highlight the issue isn't just with the datepicker's model being cleared, but also how it affects form validation, even when the field is not marked as required.

@jackpimbert
Copy link

👍 Same issue here.

@askucher
Copy link

+1

@icfantv
Copy link
Contributor

icfantv commented Feb 22, 2016

@askucher, please do not simply add +1 to issues as it adds no intrinsic value to the discussion and serves to only clutter up the thread. That said, I'm not sure what you're trying to imply with your support of this issue as we've made the switch to only support JS Date objects due to how different browsers handle dates differently.

@icfantv
Copy link
Contributor

icfantv commented May 18, 2016

@saurabh67, did you even read this thread? the last post in this issue specifically asks you not do what you did. you may use the response emojis to specify a reaction. in the future, please be respectful of our time and processes by not being lazy.

@shanzilla
Copy link

shanzilla commented Nov 16, 2016

It's not clear if this has been resolved. I'm still seeing the issue in Angular UI-Bootstrap 2.2.0.

@icfantv When you say you've made the switch to only support JS Date objects are you saying that disallowing null as valid input for the datepicker is by design? Is there a workaround for date fields that are not required?

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

No branches or pull requests