我正在使用ui bootstrap指令ui-datepicker。我想设置datepicker,用户只能选择今天的日期或未来日期。这是datepicker的html:
<div class="input-group">
<input type="text" class="form-control"
uib-datepicker-popup="yyyy-MM-dd"
name="start_date"
ng-model="loan.start_date"
is-open="popup1.opened"
datepicker-options="dateOptions"
ng-required="true"
close-text="Close"
alt-input-formats="altInputFormats"
/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
以下是我在javascript方面的内容:
$scope.inlineOptions = {
customClass: getDayClass,
minDate: new Date(),
showWeeks: true
};
$scope.dateOptions = {
dateDisabled: disabled,
formatYear: 'yy',
maxDate: new Date("2020-04-1"),
minDate: new Date() ,
startingDay: 1
};
如何提前感谢,我该如何做到这一点。
答案 0 :(得分:0)
你的javascript看起来不错,但你的加价似乎有些偏差。看看这个plunker(从Angular原版修改),这是一个有效的例子。
$scope.dateOptions = {
dateDisabled: disabled,
formatYear: 'yy',
minDate: new Date(),
startingDay: 1
};
<p class="input-group">
<input type="text" class="form-control" uib-datepicker-popup ng-model="dt" is-open="popup2.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open2()"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>