I encountered an issue while working on form validation in Angular.
An error message stated: "No directive found with exportAs 'ngModel'."
Here is a snippet of the code:
<form>
<div class="form-group">
<label for="firstname">First Name</label>
<input type="text" id="name" name="name" required minlength="4"
appForbiddenName="bob" ngModel #name="ngModel">
<div class="alert alert-danger" *ngIf>First name required</div>
</div>
<div class="form-group">
<label for="comment">Comment</label>
<textarea name="" id="comment" cols="30" rows="10" class="form-control"></textarea>
</div>
<button class="btn btn-primary">Submit</button>
</form>
The exact error was highlighted as follows:
Error: src/app/app.component.html:6:60 - error NG8003: No directive found with exportAs 'ngModel'.
6 appForbiddenName="bob" ngModel #name="ngModel">
~~~~~~~
src/app/app.component.ts:5:16
5 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
This issue occurred within the template of component AppComponent.