I am unable to validate for a minimum number on a material input, even though I can successfully validate for required
.
<input min="0.01" matInput type="number" placeholder="Amount" style="width: 49%;" [formControl]="numberControl" name="amount"
[(ngModel)]="amount" required>
<mat-hint>
<strong>Available cash: {{selectedMovementFrom?.portfolioValue | currency: 'GBP': 'symbol'}}</strong>
</mat-hint>
<mat-error *ngIf="numberControl.hasError('min')">
Amount cannot be negative.
</mat-error>
<mat-error *ngIf="numberControl.hasError('required')">
Please enter amount.
</mat-error>
I have also tried checking for validation by referencing the errors
object like so:
<mat-error *ngIf="numberControl.errors?.min">
Amount must be greater than £0.00
</mat-error>
However this also does not display the error, having checked the docs I'm still non-the-wiser.
Any pointers or obvious things I've missed?