Upon clicking the submit button, I encountered the following error:
ERROR TypeError: Cannot read property 'minlength' of null
I am unsure why this error is happening. How can I go about resolving this issue?
Below is the code from app.component.html:
<form name="form" (ngSubmit)="f.form.valid && onSubmit()" #f="ngForm" novalidate>
<div class="form-group">
<label for="categoryName">Category Name:</label>
<input type="text" class="form-control" name="categoryName" [(ngModel)]="cate.categoryName" minlength="5" #categoryname="ngModel" [ngClass]="{ 'is-invalid': f.submitted && categoryName.invalid }" required/>
<div *ngIf="f.submitted && categoryName.invalid" class="invalid-feedback">
<div *ngIf="categoryName.errors.required">
Category Name is required
</div>
</div>
<div *ngIf="categoryName?.touched && categoryName?.errors.minlength" class="invalid-feedback">
Category Name must be at least 5 characters long.
</div>
</div>
</form>