I have a page in my view and the ability to edit this page. When the "Edit" button is clicked, a child view opens and all editable fields are displayed. One field is a date picker that is tied to a modal.
The text box contains a date, but when I open the calendar, the date in the text box does not stand out in the calendar. Then I select another date and close the child view.
Now, when I open the calendar popup of another item, the selected date is highlighted. (the date in the text box is different) I was stuck with this for a while. Below is my markup
<div class="col-sm-4 ph-calendar">
<div class="input-group">
<input type="text"
id="duedate"
class="form-control"
datepicker-popup="{{dateFormat}}"
ng-model="milestone.duedate"
ph-validator="milestone.duedate"
ng-required="true"
is-open="datepickerOpenState.dueDateOpened"
datepicker-options="dateOptions"
ng-disabled="(isrecurring && isseries) || !permissions.canUpdateMilestones"
close-text="Close"
tooltip="dd/mm/yyyy"
tooltip-placement="bottom"
ph-datepicker-fix />
<span class="input-group-btn datepickerbtn">
<button type="button" class="btn btn-default" ng-click="openDatepicker($event, 'duedate')" ng-disabled="(isrecurring && isseries) || !permissions.canUpdateMilestones">
<i class="fa fa-calendar"></i>
</button>
</span>
</div>
</div>
This is my js
$scope.openDatepicker = function ($event, dateType, date) {
$event.preventDefault();
$event.stopPropagation();
switch (dateType) {
case 'duedate':
$scope.datepickerOpenState.dueDateOpened = true;
$scope.datepickerOpenState.completionDateOpened = false;
$scope.datepickerOpenState.startDateOpened = false;
$scope.datepickerOpenState.endDateOpened = false;
break;
I also do some formatting for datepicker
ngModelCtrl.$render = function () {
if (ngModelCtrl.$viewValue) {
ngModelCtrl.$viewValue = new Date(ngModelCtrl.$viewValue);
var dateVal = ngModelCtrl.$viewValue ? $filter('date')(ngModelCtrl.$viewValue, 'dd/MM/yyyy') : '';
$element.val(dateVal);
} else {
$element.val(null);
}
};