Home > Enterprise >  How validate a control form in angular 13?
How validate a control form in angular 13?

Time:05-10

I have a ractive form in angular 13 dedined like that: enter image description here

So I want to validate this form like that: enter image description here

I get the following error: enter image description here

and enter image description here

noting that in the component I have a get function like:

  get firstname() {
    return this.myGroup.get('firstname');
 } 

CodePudding user response:

The template is wrong.

<div *ngIf="firstname?.errors?.['required']">First name is required</div>
  • Related