Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update date selected and empty input #310

Open
couderA opened this issue Sep 26, 2016 · 1 comment
Open

Update date selected and empty input #310

couderA opened this issue Sep 26, 2016 · 1 comment

Comments

@couderA
Copy link

couderA commented Sep 26, 2016

I cannot update the selected date of my datepicker directly in JS.

And I would like to have my input empty rather than having the default set to today.

@lanstat
Copy link

lanstat commented Sep 28, 2016

Hi, is a problem with the filter "mFormat" and the createMoment function.
I solved with this.

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

createMoment: function (m) {
      if (tz) {
        return moment.tz(m, tz);
      } else {
          if (/\d\d\/\d\d\/\d\d\d\d/.test(m)) // Test with my format
              return moment(m, 'DD/MM/YYYY');
          else
              return moment.isMoment(m) ? moment.unix(m.unix()) : moment();
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants