Ng-bootstrap: ngb-timepicker not showing updated modal value

Created on 10 Apr 2018  路  1Comment  路  Source: ng-bootstrap/ng-bootstrap

Bug description:

I have a ngb-timepicker bound to a time structure (hour/minute). When the page loads, the time is set.
But if i change the time on click of a button (e.g., if i have some defaults that the user can tap and the timepicker shows that time), the model is updated, but the timepicker still displays the old time.

Link to minimally-working plunker that reproduces the issue:

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

Version of Angular, ng-bootstrap, and Bootstrap:

Angular: 4
@ng-bootstrap/ng-bootstrap: 1.0.0-beta.5
Bootstrap - 4.0.0-alpha.6

Issue is reproducible by modifying the plunker example on the demo page.

Angular issue timepicker invalid

Most helpful comment

You need to assign a new _instance_ of the time object: this.time = {hour: 20, minute: 45};:
http://plnkr.co/edit/kWQG1RsFHNdlo5AS0Fy6?p=preview

Otherwise ngModel will not see the change and will not inform timepicker of the change.
Sorry, there is nothing we can do about it here, this is how ngModel works...

Closing as any eventual change would have to happen in the Angular forms, we can't work-around it here in the library.

>All comments

You need to assign a new _instance_ of the time object: this.time = {hour: 20, minute: 45};:
http://plnkr.co/edit/kWQG1RsFHNdlo5AS0Fy6?p=preview

Otherwise ngModel will not see the change and will not inform timepicker of the change.
Sorry, there is nothing we can do about it here, this is how ngModel works...

Closing as any eventual change would have to happen in the Angular forms, we can't work-around it here in the library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mdelprado86 picture mdelprado86  路  3Comments

elainebyrne picture elainebyrne  路  3Comments

rolandoldengarm picture rolandoldengarm  路  3Comments

AlexKhymenko picture AlexKhymenko  路  3Comments

riksof-zzlalani picture riksof-zzlalani  路  3Comments