ng2-ui / datetime-picker

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

Not working if apply date-format attribute #188

Open SharmaHarsh7 opened 7 years ago

SharmaHarsh7 commented 7 years ago

Hi,

I am using this control in my angular2 application which is based on reactive form approach.

It is working fine when I used the default code as mentioned on your plunker but when I apply date-format attribute it is not showing anything in the text box.

It is showing calendar and allowing me to change the date but the date is not in being display in the text box.

Thanks, Harsh

allenhwkim commented 7 years ago

Please create a plunker example for this. Without a reproducible example, it's hard to tackle the problem.

SharmaHarsh7 commented 7 years ago

It is working fine with plunker but giving error on my machine when I follow the exact same steps mention by you on GIT and in Plunker.

Following is the code I am using: image

And this is the error: image

Also If I apply date-format attribute, everything goes fine but I don't see any update in the model bind to the control. Apply the code: image

Selected a date: image

The control is blank: image

It looks like the plunker and the steps you provided on GIT are outdated and not updated to the latest version on the control.

Could you please suggest any way to get rid of this issue.

Thanks. Harsh

rojarohini commented 7 years ago

i am also getting same issue while setting date-format..

aksdhaon commented 7 years ago

Same thing happening for me, the value of the datetime field becomes null on applying the date-format attribute. (Using moment.js, the parse-format attribute is working fine though)

ghost commented 7 years ago

I was facing this issue and it appears to be a bug with NPM not including moment.locale This is why it works in Plunkr, because you are using the CDN

My fix was to directly require("moment/min/locales.min") in my app.module.ts

Hope this helps someone