angular-datepicker icon indicating copy to clipboard operation
angular-datepicker copied to clipboard

Backspace not clean ng-model value

Open BilgehanYildiz opened this issue 9 years ago • 3 comments

Hi,

when I selected datetime ,it works no problem but if I used backspace,it clean value in datepicker but ng-model value still remains.How can I clean up ng-model value in that case

Regards

BilgehanYildiz avatar Jan 25 '16 14:01 BilgehanYildiz

Same here. any updates?

kuzmeig1 avatar Mar 03 '16 11:03 kuzmeig1

I cant find solution yet ,can anybody help?

BilgehanYildiz avatar Mar 04 '16 08:03 BilgehanYildiz

Hey, I've submitted a pull request with a fix, so it will trigger ng-model update if everything is backspaced.

https://github.com/kuzzmi/angular-datepicker/commit/bb1c199804a403f4bef0d1c9bcab9b0cdc643435

You can check the difference and temporarily manually apply this patch.

Essentially the diff is:

//Moment format filter.
  Module.filter('mFormat', function () {
    return function (m, format, tz) {
      if (!(moment.isMoment(m))) {
        return (m) ? moment(m).format(format) : '';
      }
      return tz ? moment.tz(m, tz).format(format) : m.format(format);
    };
  });

...

        function parser(viewValue) {
          if (viewValue.length === format.length) {
            return viewValue;
          }
          return (viewValue.length === 0) ? viewValue : undefined;
        }

kuzmeig1 avatar Mar 04 '16 08:03 kuzmeig1