[英]How to set maxdate and mindate in uib-datepicker
Below is my Controller and html code where I'm implementing date and can someone explain me how to add maxdate and mindate to below code.下面是我的控制器和 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>
You can use maxDate
and minDate
in datepicker options.您可以在日期选择器选项中使用
maxDate
和minDate
。
According to documentation根据文档
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
要配置 uib-datepicker,您需要在 Javascript 中创建一个包含所有选项的对象,并在 datepicker-options 属性上使用它
so in your html所以在你的 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" />
and in your controller并在您的控制器中
$scope.options = {
minDate: new Date(), // set this to whatever date you want to set
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.