【发布时间】:2022-12-27 21:18:40
【问题描述】:
I'm using PrimeNg 15 with Angular 14. I've two p-calendar. One for start date and other for end date. I've to make sure that End date remains disabled till the user selects a Start date. But most important thing is that End date should ALWAYS be one day ahead of start date.
HTML
<p-calendar
[(ngModel)]="startDateValue"
[showTime]="false"
[minDate]="minDateValue"
formControlName="startDate"
(onSelect)="setEndDate()">
</p-calendar>
<p-calendar
[(ngModel)]="endDateValue"
[showTime]="false"
[minDate]="endMinDate" // ngmodel of start date calendar
formControlName="endDate"
[disabled]="!allowEndDate">
</p-calendar>
TS
setEndDate() {
this.allowEndDate = true;
this.endMinDate = this.startDateValue;
this.endMinDate.setDate(this.endMinDate .getDate() + 1);
}
With this code when I selected any date from start date it is selecting one day ahead of selected date. Also in End date I'm still able to select a date which is same as start date. Please pitch in.
【问题讨论】: