I am trying to display error if user input is not alphanumeric following this example, but without success. Error message is always displayed.
This is code snippet:
<div class="col-md-4" *ngIf="this.context.risk.contractOrigin === 'Appel_d_offre'">
<label class="control-label" for="numberTenderInvitation">Numéro d'appel d'offre</label>
<input class="form-control" id="numberTenderInvitation" name="numberTenderInvitation"
[(ngModel)]="context.risk.policyId"
#numberTender="ngModel"
maxlength="10"
[pattern]="'^[a-zA-Z \-\']$'"
required/>
</div>
<small class="errorLabel" [hidden]="!numberTender.errors">
Le champ comporte une erreur.
</small>
Error that I got is:
ERROR TypeError: Cannot read property 'errors' of undefined
Where did I go wrong?