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

Inside <form>, smDateTimePicker will set a new ngModel value on load. #126

Open mtraynham opened 7 years ago

mtraynham commented 7 years ago

Inside a <form> element, the form's $dirty flag is being set on initialization when using <sm-date-time-picker>.

I believe it may be related to how you are using the ngModelCtrl on a few of these lines... https://github.com/mominsamir/smDateTimeRangePicker/blob/c81ba03b0b216d264f13a81d294a48ff44c5b1f7/src/picker.js#L1000-L1033

This line in particular, will cause an update the to the modelValue, but I think you really want to move most of this code up into the $formatter, and have the $formatter return the viewValue.

This is a good diagram of how to interact with the ngModelCtrl. https://www.bennadel.com/resources/uploads/2015/ng-model-parsing-formatting-angularjs.png