Can't bind to 'email' since it isn't a known property of 'ion-input'

I tried to add email validation with this:

<ion-item>
                <ion-input type="email" placeholder="Email" [email]="true" name="email" [(ngModel)]="registerCredentials.email" #email="ngModel" required></ion-input>
              </ion-item>
              <div>
                {{email.errors | json}}
              </div>
              <div *ngIf="email.errors && (email.dirty || email.touched)"
                   class="alert alert-danger">
                <div [hidden]="!email.errors.email">
                  Name cannot be more than 20 characters long.
                </div>
              </div>

but I get this error:

image

The error message even shows you where the problem is…

It is not obvious for me

[email]=“true”

tells angular to validate the input as email

But this doesn’t exist on <ion-input> per the error message.

No it doesn’t. Please read the documentation.

1 Like

https://angular.io/api/forms/EmailValidator

see last example?

That’s for Angular’s input. Your code uses ion-input.

1 Like

so how do i do it with ion-input?

1 Like