I am working with a popup component that includes a mat-datepicker. When the user changes the date, I need to update this value in another control and ensure that the start
and end
controls are valid. However, due to a bug in the mat-date-range-input, I encounter issues. Specifically, when I open the datepicker for the third or fourth time, I receive the error message NG0100: Expression has changed after it was checked. This occurs because ValueChanges is triggered even without any actual changes being made yet. How can I resolve this issue?
ngAfterViewInit() {
this.range.get('start').valueChanges.subscribe(() => {
this.updateFormattedDates();
this.changeDetectorRef.detectChanges();
});
this.range.get('end').valueChanges.subscribe(() => {
this.updateFormattedDates();
this.changeDetectorRef.detectChanges();
});
}
updateFormattedDates() {
...
}