mominsamir / smDateTimeRangePicker

Angular Material Date Picker, DateTime Picker, Date Range Picker, Date Time range picker
http://mominsamir.github.io/smDateTimeRangePicker/
MIT License
130 stars 50 forks source link

ng-changed in input #147

Closed kikitsa closed 5 years ago

kikitsa commented 7 years ago

I am using the date time picker and I have a problem. When I don't use attribute 'onFocus' then I can change the selected value by interacting with the input (type in text). In this case I want to be able to validate the new value on the change of the input. Could you add 'ng-changed = vm.onDateSelected(date)' in the input or ng-blur maybe? Specifically in file script.min.js in line 1125.

Could you suggest something else?

oscar09 commented 7 years ago

Can you elaborate what you are trying to accomplish? If you expect the onChange event as soon as the user picks the date on the "start Date" or "end Date" tabs, then that cannot be done with the current code since the model is updated until the "save" button is clicked. If you just want to validate the date when the input changes (after the save button is clicked) then you can just add a watch on the model.

rahimnagori commented 5 years ago

Hi @oscar09 , I'm having an issue with the following settings: https://embed.plnkr.co/pPjdbN/ <sm-date-time-picker fname="field" label="Date of Birth" ng-model="vm.employee.dateOfBirth" flex="50" flex-sm="100" flex-xs="100"
is-required="{{true}}" format="MM-DD-YYYY" mode="date" week-start-day="Monday"> Test -> Open date picker -> click OK -> Result : MM-DD-YYYY (Current Date)

Open date picker -> click cancel -> Result : MM-DD-YYYY (Previously selected date)

Open date picker -> Select a date -> click OK -> Result : MM-DD-YYYY (Selected date)


Open date picker -> Select a date -> click Cancel -> Result : Day Month DD YYYY 00:00:00 GMT+0000 (Undesired format with selected date before cancel click)

Now I want the last selected date on this last case in desired format (DD-MM-YY) as set in attribute. Can you help me with that?

oscar09 commented 5 years ago

Hi rahimnagori. As I understand, the problem is that when you select the date in the datepicker the value changes to something like "Wed Nov 28 2018 00:00:00 GMT-0600" and the value remains that way if you either click cancel or click outside of the dialog. Is that right?

rahimnagori commented 5 years ago

@oscar09 , yes you got it right. Have you got any solution for this ?

oscar09 commented 5 years ago

No. This is a bug, I am still working on the fix.

oscar09 commented 5 years ago

I just pushed a fix. Can you test the scenario again? There is still an issue pending. When you select one of the dates and you click "cancel" and you open the calendar again the date that was previously selected remains active instead of the one linked to the model. I will open a different bug for that one because the fix does not seem very easy.

rahimnagori commented 5 years ago

Hi @oscar09 , I have tested it on plunker ( https://embed.plnkr.co/pPjdbN/ ) and now it's working great. Your point, which you mentioned is also there. Thanks buddy.