【发布时间】:2014-08-21 19:27:29
【问题描述】:
我有一个使用 AngularJS 和 UI-Bootstrap 的应用程序。我有一个需要限制日期的 datePicker。我对角度很陌生,想知道是否有人知道我会如何做到这一点。我正在寻找一种方法将 minDate 设置为 90 天前,将 maxDate 设置为今天的日期。
var DatepickerDemoCtrl = function ($scope) {
$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,opened) {
$event.preventDefault();
$event.stopPropagation();
$scope[opened] = true;
};
$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];
};
【问题讨论】:
标签: angularjs angular-ui-bootstrap