下面是我的 Controller 和 html 代码,我在其中实现日期,有人可以解释一下如何将 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>
最佳答案
您可以在日期选择器选项中使用 maxDate
和 minDate
。
根据文档
to configure the uib-datepicker you need to create an object in Javascript with all the options and use it on the datepicker-options attribute
所以在你的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" />
在你的 Controller 中
$scope.options = {
minDate: new Date(), // set this to whatever date you want to set
}
看看这个 plunker
关于javascript - 如何在uib-datepicker中设置maxdate和mindate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42259339/