我是角度JS的新手,我正在尝试修复minDate
和maxDate
以及最新的选择器,我已尝试过下面的代码,但它无效:
<input type="text" name="mydate" id="sd" min-date="minDate" placeholder="Select a date" class="form-control datepicker" min-date="minDate" ng-model="enquiry.startdate" ng-blur="updateRate()" required>
<span class="input-group-addon">
<i class="fa fa-calendar"></i>
</span>
以下是我的控制器代码:
function enquiryCtrl($scope,DataServices,$stateParams,SweetAlert,$state,DTOptionsBuilder,DTColumnDefBuilder){
// some other code
var date = new Date();
$scope.minDate=date; //I am trying to set today date as minDate
}
但它没有工作它也过去的日期
以下是已编辑的代码
function getMinDate()
{
console.log("From Date---- "+$('#sd').text())
return $('#sd').val();
}
$('#dd').daterangepicker({
"singleDatePicker": true,
"dateLimit": {
"days": 7
},
"minDate":getMinDate(),
},function(start, end, label) {
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
});
$('#sd').daterangepicker({
"singleDatePicker": true,
"dateLimit": {
"days": 7
},
"startDate": new Date(),
"endDate": new Date(),
"minDate": new Date()
},function(start, end, label) {
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
});
答案 0 :(得分:0)
<div class="demo">
<p>Date: <input type="text" id="datepicker" /></p>
$(function(){ $(“#datepicker”)。datepicker({ dateFormat:“dd / mm / yy”, changeYear:true, changeYear:true, minDate:new Date(), maxDate:新日期(2017年,10-1,30) }); });