Reputation: 560
ng bootstrap with minDate throws error "minDate value must be or return a formatted date"
Component HTML:
<div class="input-group">
<input class="form-control" name="date_of_birth" type="text" ngbDatepicker #d="ngbDatepicker" id="date_of_birth" formControlName="date_of_birth" placeholder="YYYY-MM-DD" (focus)="d.open()" [minDate]="minDate">
<div class="input-group-addon" (click)="d.toggle()" role="button">
<i class="fa fa-calendar" aria-hidden="true"></i>
</div>
</div>
Component TS:
minDate: NgbDateStruct = { year: 1900, month: 1, day: 1 };
Without minDate ng datepicker working fine. After assigning minDate it throws error
Upvotes: 0
Views: 3489
Reputation: 306
The problem is most probably a clash with the ng2-validation module if it exists on your application. This module also has the same minDate and maxDate directive, which can cause conflicts in your application. So you should check that.
You should remove the reference to the ng2-validation
module in the module that is referencing the component having the error.
Upvotes: 4