ng2-ui / datetime-picker

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

defaultValue #63

Closed NaLLiFFuNT closed 7 years ago

NaLLiFFuNT commented 7 years ago

Could you add ability to add default value. By default if you open picker you see current date & time.

allenhwkim commented 7 years ago

I thought this is already there by adding year, month, date, hours, minutes. https://github.com/ng2-ui/ng2-datetime-picker/blob/master/README.md#usage-it-in-your-code

allenhwkim commented 7 years ago

Hmm, I thought it was working, https://plnkr.co/edit/k5fw7S?p=preview, but it seems not.

@NaLLiFFuNT we had better to fix this as required rather than having a fixed default value. It makes dropdown to set only some values; year, month, day, hour, or minute, not all of them.

If we want a fixed value, we can simply specify [(ngModel)] which makes to display the value initially.

@NaLLiFFuNT What do you think about that? @Krisa Do you have an opinion on this matter?

NaLLiFFuNT commented 7 years ago

I tried this way. But it didn't work to me. Also, i think the way passing one param instead of passing five params is more convenient

NaLLiFFuNT commented 7 years ago

anyway default value is NOW. if you create a Date object, default value is NOW. if you use moment, default value is NOW too. You can easily modify initial date with momentJS, which your component is required. So, i find my solution more handy.

allenhwkim commented 7 years ago

I may miss something https://gitter.im/ng2-ui/ng2-datetime-picker?utm_source=share-link&utm_medium=link&utm_campaign=share-link can we talk about it here?

allenhwkim commented 7 years ago

@NaLLiFFuNT you can pre-fill the value with [(ngModel)]. That makes I feel [defaultValue] is redundant to ngModel except it prefills the input field.

NaLLiFFuNT commented 7 years ago

I talked about value which picker shows, before you select any value