我在时间戳中按照模型值填充了以下文本输入:
<md-datepicker ng-model="ln.dateofbirth" md-current-view="year" md-date-filter="ctrl.dateOfBirth" md-max-date="maxDate" md-placeholder="Date Of Birth" required></md-datepicker>
答案 0 :(得分:0)
您需要在init方法上设置minDate和maxDate。
控制器
var minDate = new Date(Date.now());
var maxDate = new Date(Date.now());
var startDate = maxDate;
// setting the min date and thus the max birth date allowing < 100 year old choosable birthdate
this.minDate.setDate( this.minDate.getDate() );
this.minDate.setFullYear( this.minDate.getFullYear() - 100 );
// setting the calendar's start date and youngest birth dates for > 18 years old
this.maxDate.setDate( this.maxDate.getDate() );
this.maxDate.setFullYear( this.maxDate.getFullYear() - 18 );
this.startDate = this.maxDate;
查看强>
<md-datepicker ng-model="ln.dateofbirth" md-current-view="year" md-date-filter="ctrl.dateOfBirth" md-min-date="minDate" md-max-date="maxDate" md-placeholder="Date Of Birth" required></md-datepicker>
查看mdDatepicker API Documentation了解更多详情。