I'm working with p-calendar. When I select a random date, I want only a range of 15 dates to be selected and all the futures dates after this range. This is my code:
onSelect(event: Event) {
const invalidDate = new Date();
const selectedDate = new Date(minDate);
const invalidDates: Date[] = []
invalidDate.setMonth(selectedDate.getMonth());
invalidDate.setDate(selectedDate.getDate() + 15);
while (invalidDate <= maxDate) {
invalidDates.push(new Date(invalidDate));
invalidDate.setDate(invalidDate.getDate() + 1);
}
and the template code
<p-calendar
formControlName="dates"
selectionMode="range"
[maxDateCount]="2"
[maxDate]="maxDate"
[disabledDates]="invalidDates"
(onSelect)="onSelect($event)"
></p-calendar>
after selecting selecting a random date, the future date after the range of 15 days are not disable even if I apply [disabledDates]="invalidDates"
Any idea to make dates disabled by using my function ?