formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 406 forks source link

Datetimepicker sample not working as expected? #690

Open fuzzball1980 opened 8 years ago

fuzzball1980 commented 8 years ago

Hi guys!

I have been locking at the datetimepicker sample

http://angular-formly.com/#/example/other/date-time-picker

If you set a datetime model at startup the Date part of the model is not updated on the UI, only until you make a change on the UI (change the time) the date part is reflected.

Do anyone know if if is a formly problem or a angular-datetimepicker problem?

Thanks!

maliknur commented 8 years ago

Seems to be more angular-datetimepicker issue.

shailendramonu commented 8 years ago
Bug description:

Initial value is not populating when load by modal (ng-model="model[options.key]")

Link to minimally-working plunker that reproduces the issue:

http://jsbin.com/yesayiwowi/edit?html,js,output

Try giving initial value to model e.g. vm.model = {"datetime": "2016-07-04T14:00:00.000Z"};

Fix (ui.bootstrap.datetimepicker) datetimepicker.js -> template -> controller after line 178
if ($scope.ngModel) {
 // convert from ISO format to Date
  if (!($scope.ngModel instanceof Date)) $scope.ngModel = new Date($scope.ngModel);
}