ng-matero / extensions

Angular Material Extensions Library.
https://ng-matero.github.io/extensions/
MIT License
388 stars 48 forks source link

<mat-error> not showing up on <mtx-datetimepicker> #275

Closed morrowyn closed 2 months ago

morrowyn commented 3 months ago

Hi, I have a mtx datetime picker input field, but when I add a to the form field. The error doesn't show up. The form field does become red meaning that there is an error. But the containing the error message is absent. Any idea what is happening?

The documentation/demo doesn't show how to add a , so I'm a bit in the dark here.

I'm using Angular 15 and @ng-matero/extensions": "^15.6.1"

I also noticed that when another field gets into error state, then the mtxdatetimepicker get triggered for validation. However the and are not showing up.

I have the following code:

         <mat-form-field appearance="outline">
              <mat-label>Start Date</mat-label>
              <input
                class="ng-trim-ignore"
                matInput
                [mtxDatetimepicker]="startDatePicker"
                formControlName="startDate"
              />
              <mtx-datetimepicker-toggle
                matSuffix
                [for]="startDatePicker"
              ></mtx-datetimepicker-toggle>
              <mtx-datetimepicker #startDatePicker
                [twelvehour]="false"
                [timeInput]="false"
                [mode]="'auto'"
                [type]="'datetime'"
                [timeInterval]="1"
              ></mtx-datetimepicker>
              <mat-error
                *ngIf="
                formGroup
                    .get('startDate')
                    .hasError('required') &&
                    formGroup.get('startDate').touched
                "
              >
                <span>Start date is required</span>
              </mat-error>
              <mat-error
                *ngIf="
                  formGroup
                    .get('startDate')
                    .hasError('EndDateBeforeStartDate') &&
                  formGroup.get('startDate').touched
                "
              >
                <span>Start date must lie before end date</span>
              </mat-error>
            </mat-form-field>
nzbin commented 3 months ago

Can you provide an online example?