2017-02-15 31 views
0

下面是我的控制器和html代码,我正在实施日期,并且有人可以向我解释如何向下面的代码添加maxdate和mindate。如何在uib-datepicker中设置maxdate和mindate

app.controller('viewfullproductionsummaryController', function ($scope, productionService, usSpinnerService) { 
 
    $scope.open1 = function() { $scope.popup1.opened = true; }; 
 
    $scope.popup1 = { opened: false }; 
 
    $scope.data = {}; 
 
    $scope.data.ProductionReportDate = new Date(); 
 
    });
<div class="col-md-2 inputGroupContainer"> 
 
    <div class="input-group"> 
 
     <span class="input-group-btn"> 
 
     <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button> 
 
     </span> 
 
     <input type="text" class="form-control" uib-datepicker-popup="dd-MMM-yyyy" ng-model="data.ProductionReportDate" is-open="popup1.opened" required close-text="Close" /> 
 
    </div> 
 
</div>

回答

1

可以在日期选择器选项使用maxDateminDate

根据文档

配置UIB,日期选择器,你需要创建 的Javascript对象与所有的选择和使用它的日期选择器选项 属性

所以在您的html

<input type="text" class="form-control" uib-datepicker-popup="dd-MMM-yyyy" ng-model="data.ProductionReportDate" is-open="popup1.opened" datepicker-options="options" required close-text="Close" /> 

并在您的控制器中

$scope.options = { 
     minDate: new Date(), // set this to whatever date you want to set 
    } 

看一看这个plunker

+0

我试图采取的但他们不工作。你能告诉我用excat代码如何实现? – Ranger

+0

我已经更新了我的答案,看看 –

+0

非常感谢Nishant。它为我工作... :))) – Ranger

2

AngularJS您可以设置一系列dateOptions如dateMin,dateMax为uib-datepicker

入住这plunker从这个thread

相关问题