Using the Angularjs Bootstrap datepicker has been a great experience, but I encountered a problem when attempting to select the date using JavaScript. How can I ensure that the selected date in the datepicker matches the date read from a specific object, such as 4/5/1990?
Hint: This functionality is needed when presenting data for user editing.
Review my current code:
HTML
<input type="text" class="form-control" ng-model="Birthdate" id="Birthdate" name="Birthdate" required autocomplete="on" datepicker-popup="dd/MM/yyyy" is-open="opened" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)"
ng-required="true" close-text="Close" placeholder="Enter Birthdate" />
JavaScript
$scope.Birthdate = $scope.users[id].Birthdate;
However, two issues arise with the selected date:
First issue: When the date is 4/5/1986, the day and month are swapped in the date format. For example, 4/5/1990 becomes 5/4/1990.
Second issue: No date is selected if the date is 28/5/1986.
I am seeking assistance on how to have the datepicker select the date exactly as it is read from the object. If the date is 4/5/1990, the datepicker should show that date without any alterations. Similarly, if the date is 28/5/1986, the datepicker should select that date accurately.