uib-datepicker 中的条件最小和最大日期

conditional min and max date in uib-datepicker

我想在 ng-repeat 中添加一个 uib-datepicker。每个项目都有自己的最小和最大日期,所以我想有条件地将其设置为日期选择器。

目前我有这个,但它不起作用:

<p class="input-group">
   <input class="form-control" type="text" uib-datepicker-popup="dd-MM-yyyy" ng-model="task.datePlanned" is-open="popup.opened" datepicker-options="dateOptions($index)" close-text="Sluiten">
   <span class="input-group-btn">
       <button class="btn btn-default" type="button" ng-click="openDate()">
           <i class="fa fa-calendar"></i>
       </button>
    </span>
</p>

控制器:

$scope.dateOptions = function(index){
    return {
        maxDate: new Date($scope.campaign.tasks[index].endDate),
        minDate: new Date($scope.campaign.tasks[index].startDate)
    }
}

$scope.openDate = function(){
    $scope.popup.openend = true;
}

$scope.popup = {
    openend: false
}

我在 minmaxdate 处收到 Error: [$rootScope:infdig] 错误。

有没有办法向选择器添加条件日期?

Each item has it own min and maxdate, so I want to conditional set this to the datepicker.

如果要求为每个项目设置单独的最小值、最大值,您可以在标签本身中扩展对象定义,如下所示:

<p class="input-group">
   <input class="form-control" type="text" 
       uib-datepicker-popup="dd-MM-yyyy" 
       ng-model="task.datePlanned" 
       is-open="popup.opened" 
       datepicker-options="{
                     maxDate: task.endDate,
                     minDate: task.startDate
                 }" 
       close-text="Sluiten">
   <span class="input-group-btn">
       <button class="btn btn-default" type="button" ng-click="openDate()">
           <i class="fa fa-calendar"></i>
       </button>
  </span>
</p>