2
在應用程序中使用AngularJS UI datePicker,在表單上有三個日期輸入。無論選擇和保存的日期如何,這一天總是提前一天。我已經嘗試了日期格式的每一個組合,並搜索這個主題的每一個論壇帖子,但沒有任何作品。我可以更改我的代碼以便在選擇日期時獲得正確的日期?AngularJS UI datePicker總是有一天關閉
JS
configAppControllers.controller('deadLineDatePickerCtrl', ['$scope', '$timeout',
function ($scope, $timeout) {
$scope.today = function() {
$scope.dt = new Date();
};
$scope.today();
$scope.clear = function() {
$scope.dt = null;
};
// Disable weekend selection
$scope.disabled = function (date, mode) {
// return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
};
$scope.toggleMin = function() {
$scope.minDate = $scope.minDate ? null : new Date();
};
$scope.toggleMin();
$scope.open = function ($event, id) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = true;
$timeout(function() {
$("#" + id).focus();
});
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
$scope.initDate = new Date('2012/03/21');
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
$scope.format = $scope.formats[3];
}
]);
HTML
<div class="input-group deadline">
<input name="deadLine" id="deadLine" type="text" class="form-control"
data-ng-required="true"
datepicker-popup="{{format}}"
data-ng-model="programDetails.deadline"
is-open="opened"
min-date="programDetails.startDate"
datepicker-options="dateOptions"
date-disabled="disabled(date, mode)"
close-text="Close"
show-button-bar="false"/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" data-ng-click="open($event)"><i
class="fa fa-calendar"></i></button>
</span>
這對我來說,非常感謝。 – 2017-03-06 12:05:33