I can’t get a validation message to show on an input type. I’m using for validator.pattern with Form Group and not sure why it will not show. The mat-error tag will not show. I’m looking for help with a possible solution to this for anything over two decimal places. If someone could help me with this I would appreciate.
html
<div class="col-md-3 offset-md-1"> <mat-form-field appearance="legacy" floatLabel="always"> <mat-label>Breakfast</mat-label> <input matInput type="number" class="example-right-align" placeholder="0" formControlName="bfastAmount" /> <span matPrefix>$ </span> <mat-error *ngIf="form.controls['bfastAmount'].errors?.pattern" class="text- danger">Please provide a valid amount.</mat-error> </mat-form-field> </div>
ts
form: FormGroup = new FormGroup({ bfastAmount: new FormControl('', [Validators.pattern('^\\d{1,2}\\.\\d{2}$')]), });