![](/img/trans.png)
[英]Angular ngx-bootstrap datepicker how to limit future month and year
[英]How to disable Today and future dates in angular by using ngx-bootstrap datepicker?
dob: Date;
public maxDob: Date;
const year = this.dob.getFullYear() - 18;
const month = this.dob.getMonth();
const date = this.dob.getDate();
this.maxDob = new Date(year, month, date);
formInitialization(customerDetail ? : any) {
dateOfBirth: [customerDetail ? customerDetail.dateOfBirth : ''],
}
<div class="col s4">
<mat-form-field appearance="outline" class="common-form-field-width">
<input readonly #dateFormat matInput
formControlName="dateOfBirth" [max]="maxDob" [matDatepicker]="picker"
placeholder="Date of Birth">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.