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

bug(time-picker): binding to a string #4777

Closed
dylanvdmerwe opened this issue Feb 12, 2020 · 0 comments · Fixed by #4949
Closed

bug(time-picker): binding to a string #4777

dylanvdmerwe opened this issue Feb 12, 2020 · 0 comments · Fixed by #4949
Assignees

Comments

@dylanvdmerwe
Copy link

Reproduction link

https://stackblitz.com/edit/angular-acn5ao

Steps to reproduce

Bind an nz-time-picker to a proper string variable.
The initial binding works perfectly.
Trying to change the time throws errors and does not work.

time: string = '2020-02-12T18:16:55.6674440 02:00';

What is expected?

As with the date picker, you should be able to bind to a string value and have the component recognize it's not a string and do an internal conversion.

What is actually happening?

Error: Uncaught (in promise): TypeError: this._value.getHours is not a function
TypeError: this._value.getHours is not a function
    at TimeHolder.set [as value] (time-holder.ts:73)
    at TimeHolder.setValue (time-holder.ts:89)
    at NzTimePickerPanelComponent.writeValue (nz-time-picker-panel.component.ts:496)

The control does not work and the resulting binding is not updated.

Environment Info
ng-zorro-antd 8.5.2
Browser Chrome

In our example, we have a model that is generated from a REST API. We cannot control the model, or change it to convert fields to Date instead of a string. On the generated class there will be fields whose times need to be set. There may not be one field, but multiple (in an ngFor for example).

These are standard ISO format strings as seen in the example. On first glance, binding to the control looks to be working. But as soon as you attempt to change the time things break which is unexpected.

Note that binding to a string works for the date picker (https://stackblitz.com/edit/angular-srcksz).

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.

3 participants