ng2-datetime
ng2-datetime copied to clipboard
Dynamically changing the datepicker date from backend not working as expected
We are using Javascript with angular2 in our application Based on the user operations the datepicker date will change based on backend functionality . The issue is that when we make changes repeatedly w.r.t to the date from backend ONLY and on saving the data , the first initial value which was shown to the user is updated in backend , even when the date changes is shown in the screen via two way binding. ( The user has not selected the date via the picker)
We are not using jquery(backend coding with jquery not allowed, but external 3rd party packages can have it) in the application.
is there any solution for this?
scenario explained:
1st time when the date is shown to the user , the date picker when opened/clicked we can see the date highlighted.
when in backend code, based on some logic, the date needs to be changed. when we update the variable which is linked to the ngmodel, the user can see the date changed and on click on the datepicker the changed date is also highlighted.
But when we try to save the date, it will never show the updated date, instead the old date is shown.
But when I select the date from the datepicker , the value is updated correctly.
So i would like to know if there is an option where we can manually trigger some update to the datepicker, and get the date updated. Seems like Datepicker is not taking the new value or the change method is not invoked.
We are not using Jquery in our application. Its pure javascript based.
Update:
When I use the ngmodel variable as a string . I can see that the value is getting changed in the backend based on the user interaction with the other fields.
But the issue now is that the date is never shown in the datepicker( The place were we can enter the date manually) and when the datepicker icon is selected the default date(which comes from backend) is not highlighted as well. I still see the message "Choose a Date" in the field.
-- When I had used the ngmodel as a Date type, I could see that the selected date would be highlighted in blue color. But the value was not get updated when making multiple change without using the datepicker manually
-- Could some one let me know what is going wrong or needs to be changed?