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

main-es2015.acca8c05bb7aa8144e3f.js:1 ERROR TypeError: this._value.setHours is not a function #4871

Closed
BrsJsk opened this issue Mar 12, 2020 · 4 comments · Fixed by #4949
Closed
Assignees

Comments

@BrsJsk
Copy link

BrsJsk commented Mar 12, 2020

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-78vvuu

Steps to reproduce

  • Add a time picker
  • Model for time picker is set
  • Value is date but type is string

What is expected?

Its expected to still work even date is passed as a string. This can create issues when dates are returned from API call as strings and not formatted to date beforehand, currently we need to format it always as date and then pass it to the component.

Time picker should IMO check if it is a string, and convert it to a date so it can use setHours methods etc

What is actually happening?

Time picker component is not converting it to a Date object and therefore throwing an error.

Environment Info
ng-zorro-antd 8.3.0
Browser 80.0.3987.132 Chrome

Ran into this bag when I was passing date value to the time picker.
After a API call, I passed date to time picker but it threw an error as API returned it as a string.

@BrsJsk
Copy link
Author

BrsJsk commented Mar 12, 2020

Will open a pull request for this.

@BrsJsk
Copy link
Author

BrsJsk commented Mar 12, 2020

Created: #4872

@dylanvdmerwe
Copy link

Is this similar? #4777

@BrsJsk
Copy link
Author

BrsJsk commented Mar 12, 2020

Identical issue.
Did not see that issue.

hsuanxyz pushed a commit that referenced this issue Apr 1, 2020
* fix(module:time-picker): allow inputting string type

Fixes #4775, Fixes #4777, Fixed #4871, close #1679
Ricbet pushed a commit to Ricbet/ng-zorro-antd that referenced this issue Apr 9, 2020
* fix(module:time-picker): allow inputting string type

Fixes NG-ZORRO#4775, Fixes NG-ZORRO#4777, Fixed NG-ZORRO#4871, close NG-ZORRO#1679
@hsuanxyz hsuanxyz mentioned this issue Apr 15, 2020
hsuanxyz pushed a commit to hsuanxyz/ng-zorro-antd that referenced this issue Aug 5, 2020
* fix(module:time-picker): allow inputting string type

Fixes NG-ZORRO#4775, Fixes NG-ZORRO#4777, Fixed NG-ZORRO#4871, close NG-ZORRO#1679
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants