Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

[Date picker] Calendar is not rendering when model is a timestamp #5191

Closed
bogdanalexe90 opened this issue Jan 9, 2016 · 8 comments
Closed

Comments

@bogdanalexe90
Copy link
Contributor

Calendar is not rendering when model is a timestamp. This issue happens only with angular 1.5 and only when the popup is opened first time.

http://plnkr.co/edit/i2y5RqCzvyro8O7NVryg?p=preview

@wesleycho
Copy link
Contributor

There was a breaking change made a couple of releases ago where we decided we only want to support usage of a Date instance due to various issues & complexity supporting multiple formats.

This Plunker works fine if it is a date object, as seen here.

@bogdanalexe90
Copy link
Contributor Author

Strange... It was working fine before 1.0.0. if it's not supported anymore you can update the error message from:

this.render = function() {
    if (ngModelCtrl.$viewValue) {
      var date = new Date(ngModelCtrl.$viewValue),
          isValid = !isNaN(date);

      if (isValid) {
        this.activeDate = dateParser.fromTimezone(date, ngModelOptions.timezone);
      } else if (!$datepickerSuppressError) {
        $log.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');
      }
    }
    this.refreshView();
  };

@wesleycho
Copy link
Contributor

There were a lot of changes made in the datepicker from 0.14.3 to 1.0.0, namely to support user-specified timezones of relevance here.

I'll update the error string, sorry about the misreported message there.

Edit: Looks like it is changed in 1.0.0 to $log.warn('dateparser:', 'baseDate is not a valid date');

@bogdanalexe90
Copy link
Contributor Author

The error highlighted is in UibDatepickerController.

But... The example in my plnkr was working fine with angular 1.4.8.
The problem appears only with 1.5.0.

Here is the plnkr:
http://plnkr.co/edit/ezAsvnY8EbDkpuJ4WCUp?p=preview

@wesleycho
Copy link
Contributor

Ah, I thought it was in the dateparser - I'll open a PR for this shortly.

@bogdanalexe90
Copy link
Contributor Author

Still. Have a look on the last plnkr. Timestaps are working wit angular 1.4.8

wesleycho added a commit that referenced this issue Jan 10, 2016
- Change error message to reflect what is officially supported as a model value

Closes #5198
Fixes #5191
@wesleycho
Copy link
Contributor

We declared in release 0.13.2 that we are only supporting date objects, as seen here. Our documentation also declares only support for date objects - this is not going to change.

@bogdanalexe90
Copy link
Contributor Author

Not pushing for a change. It seems a little bit weird that the error with angular 1.5 is more an uncatched error than an error throwed by the library.

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

Successfully merging a pull request may close this issue.

2 participants