In my Angular form, I have two date pickers for selecting a start date and an end date. I need to ensure that the minimum value for the end date is set as the start date. To achieve this, I created a method that updates the min value of the end date whenever the start date changes. However, when I open the form in edit mode and populate the data, I encounter a validation error because the previously assigned [min] value still exists in the this.min variable. I need to reset it before setting the new min value based on the start date. How can I accomplish this?
<kendo-datepicker
formControlName="startDate" placeholder="Start Date" [format]="'MM/dd/yyyy'" (valueChange)=selectedStartDate() required>
</kendo-datepicker>
<kendo-datepicker
formControlName="endDate" placeholder="END Date" [format]="'MM/dd/yyyy'" [min] = "min" required>
</kendo-datepicker>
app.component.ts
min:Date;
public selectedStartDate(){
const formModel = this.specialDayFormGroup.value;
if (formModel.startDate) {
this.min = new Date(formModel.startDate);
}
}