0

I have the following date range picker:

<mat-form-field>
     <mat-label>Label</mat-label>
          <mat-date-range-input
            [rangePicker]="picker">
            <input formControlName="dateRangeFrom" id="dateRangeFrom" matStartDate
              placeholder="From">
            <input formControlName="dateRangeTo" id="dateRangeTo" matEndDate
              placeholder="To">
          </mat-date-range-input>
          <mat-error *ngIf="filterForm.controls.dateRangeFrom.hasError('matDatepickerParse')">
            Parse Error
          </mat-error>
          <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
          <mat-date-range-picker #picker></mat-date-range-picker>
        </mat-form-field>

Even tho the control has the error, and when debugging, hasError returns true, the mat-error doesnt get displayed. When i put it outside the form-field, it does get displayed, but of course thats not what i want. Any idea why this happens ?

ViqMontana
  • 5,090
  • 3
  • 19
  • 54
  • 1
    is this problem https://stackoverflow.com/questions/62937092/how-to-trigger-the-display-of-mat-error-in-a-mat-form-field-for-a-mat-date-range ? – Eliseo Jul 23 '20 at 09:11
  • @Eliseo No, I can set the custom errors (not like in the question) but the mat-error does not get displayed – Samuel Schwienbacher Jul 23 '20 at 09:14
  • 1
    sorry, I only ask. It's true that the error don't appear but the only thing I can think is making a validator about the range (as the link in my comment) – Eliseo Jul 23 '20 at 09:29
  • But that will not fix my problem, the correct error is already set, what does it help me to set one manually ? – Samuel Schwienbacher Jul 23 '20 at 09:30

0 Answers0