Angular-UI Datepicker最小日期设置与另一个日期

时间:2018-04-06 08:06:53

标签: javascript html angularjs angular-ui-bootstrap angular-ui

当用户使用angular-ui Datepicker输入日期范围时,我想要注意EndDate设置' StartDate`。

在我看来,

<div class="input-daterange input-group" id="datepicker">
  <input type="text" class="input form-control" name="ev_StartDate"
   ng-model="evStartDate" ng-required="true" is-open="startPop.opened"
   ng-focus="openStart()" uib-datepicker-popup="{{format}}" 
   alt-input-formats="altInputFormats" datepicker-options="startDateOptions" 
   readonly="true">
  <span class="input-group-addon">~</span>
  <input type="text" class="input form-control" name="ev_EndDate" 
   ng-model="evEndDate" ng-required="true" is-open="endPop.opened" 
   ng-focus="openEnd()" uib-datepicker-popup="{{format}}" 
   alt-input-formats="altInputFormats" datepicker-options="endDateOptions" 
   readonly="true">
</div>

哪个指令正确使用?

$scope.startDateOptions = {
  showWeeks: false,
  startingDay: 1
};

$scope.setOption = function() {
   ????????
  };

$scope.endDateOptions = {
  showWeeks: false,
  startingDay: 1,
  minDate: ?????
};

1 个答案:

答案 0 :(得分:2)

您可以使用min-date属性,您可以直接传入startdate的范围变量evStartDate。将以下属性添加到结束日期输入元素。

min-date="evStartDate"