ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

Issue #123 (formatted date when ngModel changes) reverted in 0.14? #160

Closed Farplaner closed 7 years ago

Farplaner commented 7 years ago

It seems that issue #123 was reverted in commit listed here: https://github.com/ng2-ui/ng2-datetime-picker/commit/932ec8768d3985ab1f4f1c66c553cbbc5c2546e2

With the code reverted, the issue happens again when the ngModel date changes externally, the date in the textbox does not get formatted.

allenhwkim commented 7 years ago

@Farplaner It is not reverted AFAIK. If you change ngModel by program, it does not change. This behaviour is never fixed(https://github.com/ng2-ui/ng2-datetime-picker/issues/143) and waiting for help.

Farplaner commented 7 years ago

What I meant was, that this commit https://github.com/ng2-ui/ng2-datetime-picker/commit/bd23140910b5968bb7d777cd18f34a9ac4311ea1 is not found in the latest codebase. It got lost between builds 0.13 and 0.14

See: https://github.com/ng2-ui/ng2-datetime-picker/blob/0.13.2/src/ng2-datetime-picker.directive.ts

Vs

https://github.com/ng2-ui/ng2-datetime-picker/blob/0.14.0/src/ng2-datetime-picker.directive.ts

(See ngOnChanges method)

allenhwkim commented 7 years ago

That lines have been removed because of the refactoring.

https://github.com/ng2-ui/ng2-datetime-picker/commit/932ec8768d3985ab1f4f1c66c553cbbc5c2546e2#diff-a6d3452287aade41af42dca7a19fbb5aL152

If the issue happens again, could you tell me how to re-produce the error? I might not have enough test cases. My test passes, but I don't think it covers all.

JayaniSumudini commented 7 years ago

@allenhwkim I used ng2-datetime-picker and I want to closed it when I clicked on input box.I tried it by developing my code using various types.Please give your kind regards to my problem.

Farplaner commented 7 years ago

Here's a plunkr that shows the problem: https://plnkr.co/edit/PcRGgUwSWk7XWcME0gt0?p=preview

When you click the button, the updated date is not formatted.

allenhwkim commented 7 years ago

@Farplaner thanks for it. It's duplicate issue of #143. I have tried, failed, thus it was never fixed. Only thing you can do is to add toString method to your ngModel at this moment. :(

this.myDate.toString= () => Ng2Datetime.formatDate(myDate, `YYYY-MM-DD`)
Farplaner commented 7 years ago

I'm sorry that maybe I didn't get my intent across... but this commit https://github.com/ng2-ui/ng2-datetime-picker/commit/bd23140910b5968bb7d777cd18f34a9ac4311ea1 actually fixed the problem for me, but it was removed due to refactoring.

allenhwkim commented 7 years ago

OK, I will put that back and try, and check again.

allenhwkim commented 7 years ago

@Farplaner you were right, I made it back and tested and it worked. Thanks for your patience.

Farplaner commented 7 years ago

Thank you for the fix. I updated to the new 0.14.6 version and it works for me now.