Javascript AngularUI引导日期选择器设置最小日期
我正在运行最新的AngularUI引导程序,我有一个日期选择器,当点击按钮打开它时,它就会被启用 我已经尝试并搜索了如何禁用被点击日期的答案,我希望最短日期为2013年1月1日-这意味着2012年12月31日及更久的日期将不可选择 下面是我的代码 ANGULARJSJavascript AngularUI引导日期选择器设置最小日期,javascript,angularjs,angularjs-scope,angular-ui-bootstrap,Javascript,Angularjs,Angularjs Scope,Angular Ui Bootstrap,我正在运行最新的AngularUI引导程序,我有一个日期选择器,当点击按钮打开它时,它就会被启用 我已经尝试并搜索了如何禁用被点击日期的答案,我希望最短日期为2013年1月1日-这意味着2012年12月31日及更久的日期将不可选择 下面是我的代码 ANGULARJS $scope.today = function() { $scope.dt = new Date();
$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>
嘿,唐纳德,我正在整理我的旧答案,如果这对你有帮助,请将此标记为已回答。格雷西亚斯。