在 ui.bootstrap.datepicker Angularjs 禁用未来日期
Disable future days at ui.bootstrap.datepicker Angularjs
我正在使用 datepicker of UI Bootstrap: (there is a Plunker there 通过按钮禁用过去的日子)。
任何人都可以帮我禁用没有任何按钮的未来日子吗?
我试过那样改变按钮的功能,但没有用:
$scope.toggleMin = function() {
$scope.options.minDate = $scope.options.minDate ? **new Date()** : **null** ;
};
这是一个按钮,我想在没有按钮的情况下禁用。
只需将 options
中的 maxDate
设置为您要限制的日期。
$scope.options = {
customClass: getDayClass,
maxDate: new Date(), // restrict maximum date to today
showWeeks: true
};
否则,如果您需要在设置选项后更改它,您可以这样做:
$scope.options.maxDate = new Date(), // restrict maximum date to today
这是禁用了今天后几天的更新后的 Plunker:https://plnkr.co/edit/0iqNNEcATzv4t8h8n41X?p=preview
设置日期选择器 class 并设置 endDate = new Date()
$('.date-datepicker').datepicker({
autoclose: true,
endDate: new Date()
});
我正在使用 datepicker of UI Bootstrap: (there is a Plunker there 通过按钮禁用过去的日子)。
任何人都可以帮我禁用没有任何按钮的未来日子吗?
我试过那样改变按钮的功能,但没有用:
$scope.toggleMin = function() {
$scope.options.minDate = $scope.options.minDate ? **new Date()** : **null** ;
};
这是一个按钮,我想在没有按钮的情况下禁用。
只需将 options
中的 maxDate
设置为您要限制的日期。
$scope.options = {
customClass: getDayClass,
maxDate: new Date(), // restrict maximum date to today
showWeeks: true
};
否则,如果您需要在设置选项后更改它,您可以这样做:
$scope.options.maxDate = new Date(), // restrict maximum date to today
这是禁用了今天后几天的更新后的 Plunker:https://plnkr.co/edit/0iqNNEcATzv4t8h8n41X?p=preview
设置日期选择器 class 并设置 endDate = new Date()
$('.date-datepicker').datepicker({
autoclose: true,
endDate: new Date()
});