g1eb / angular-datetime-range

📅 Angular directive for datetime range input
https://rawgit.com/g1eb/angular-datetime-range/master/
MIT License
25 stars 14 forks source link

Feature for null start/end dates #16

Open amit777 opened 6 years ago

amit777 commented 6 years ago

Would it be possible to allow for null values for the start and ends dates. Null would indicate indefinite start or end. Kind of like infinity.

g1eb commented 6 years ago

Let me see if I understand you correctly, you want to have unset datetime objects before the user selects a date, right? Right now if the date is not set it's 'undefined' by default and shows a placeholder instead. What would be the displayed as a placeholder for a null value?

amit777 commented 6 years ago

oh, sorry, if it's undefined then that should work! I think I missed that. My goal is to let someone say "X starts on 2/2/18 and goes indefinitely". I could just create a button that sets either the start or end to undefined then.

amit777 commented 6 years ago

so if I tried to use the directive and both start and end are undefined, I am not able to click either the start or end date. I just see this:

<datetime-range start="item.start" end="item.end"></datetime-range>

screen shot 2018-01-21 at 3 48 52 pm

amit777 commented 6 years ago

If i set item.start to a new moment(0), then if I click the undefined item.end date, i get the following error in console:

TypeError: Cannot read property 'clone' of undefined
    at m.a.selectDate 
g1eb commented 6 years ago

Ahh, interesting... It seems like the start and end dates can not be undefined after all. I think I was confused with the other angular datetime input directives that has placeholders..

Would you be able to use start and end datetime as separate directives from the other library or would you prefer adding placeholders and undefined range support here?

stanglt commented 6 years ago

I would highly appreciate such a feature in this one. With two of the other i still would have to encapsulate it to another directive to be have validations and so on.