AngularUI Bootstrap Datepicker设置最短日期
问题描述:
我正在运行最新的AngularUI Bootstrap,并且我有一个Datepicker,它在被按钮打开时被启用。AngularUI Bootstrap Datepicker设置最短日期
我已经试过并搜索了解如何禁用日期被点击的答案,我希望2013年1月1日的最低日期 - 意思是2012年12月31日,而旧版本将不可选。
下面是我的代码
ANGULARJS
$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() {
$timeout(function() {
$scope.opened = true;
$scope.minEndDate = '2013-01-01';
});
};
$scope.dateOptions = {
formatYear: 'yy',
startingDay: 1
};
$scope.initDate = new Date('2016-15-20');
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
$scope.format = $scope.formats[0];
HTML
<input type="text" class="form-control input--text" datepicker-popup="{{format}}" ng-model="newperson.dob" is-open="$parent.opened" min="minEndDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
<button type="button" class="datepicker-btn" ng-click="open()"><i class="fa fa-calendar"></i></button>
答
属性是min-date
你方才min
有:
<input type="text" class="form-control input--text" datepicker-popup="{{format}}" ng-model="newperson.dob" is-open="$parent.opened" min-date="minEndDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
<button type="button" class="datepicker-btn" ng-click="open()"><i class="fa fa-calendar"></i></button>
嘿唐纳德,只是对我的旧回答进行清理,如果这恰好帮助你,请将此标记为已回答。格拉西亚斯。 – acg 2014-09-23 13:46:04