indrimuska / angular-moment-picker

Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
http://indrimuska.github.io/angular-moment-picker/
MIT License
525 stars 226 forks source link

ng-model bugged with locale != "en" double binding systematically sets to undefined #243

Open alexandredumat opened 6 years ago

alexandredumat commented 6 years ago

There is a bug with the double binding on ng-model when locale is set to anything OTHER THAN "en" you can try for example "fr" ! Moreover you need to remove the format="YYYY-MM-DD" property that some how forces back the component to locale="en" thus preventing the error.

Very easy to reproduce :

open your plunker https://embed.plnkr.co/hs10SM change locale="en" to locale="fr" remove format="YYYY-MM-DD" click on "set to today" you'll see that it set date to undefined or null

This makes the plugin impossible to use for any other language than English, and i hope that with this steps to reproduce it you'll be able to patch it (I tryed to look at your code but didn't manage to find any hint of solution).

abhisheksiddhu commented 6 years ago

@alexandredumat I guess it's because, it's passing locale, where a boolean needs to be passed to moment. Check this out

https://github.com/indrimuska/angular-moment-picker/blob/master/src/utility.ts#L32

MartinPlaceloop commented 6 years ago

After getting a big headache on this, the answer is so simple...

moment needs to be in the same locale as angular-moment-picker

just do moment.locale("fr")