ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

When date is changed from backend the ngmodel is not updated in backend code #143

Closed AngularTx closed 7 years ago

AngularTx commented 7 years ago

Based on the business rules and checkbox selection the Date will be changed accordingly.

In my case, the date change is shown in the datepicker , but the ngmodel never gets update. Could be that the datepicker change method is not getting triggered, so the model value remains the first initial value. (But when i select from the datepicker, the updation is fine)

Is there a way that we can make the trigger manually . We are not using jquery in our application(except 3rd application)

allenhwkim commented 7 years ago

Given no plunker example, it seems duplicate to https://github.com/ng2-ui/ng2-datetime-picker/issues/76.

You should provide toString value manually for each change because (change) cannot be invoked with only program without user interaction.

I wish I had a better solution than this.

import { Ng2Datetime } from 'ng2-datetime-picker';
...
    this.myDate.toString= () => Ng2Datetime.formatDate(myDate, `YYYY-MM-DD`);