0

<input type ="email" name="myEmail">

In anuglar 1 it has error and could achive soomthing like this ( myForm.myEmail.$error.email)if it is not correct email id but it is not in case of Angular 2 , how to validate it in angular 2 ?

1 Answers1

1
<input type="text" class="form-control" placeholder="Enter Email" [(ngModel)]="notificaion.mail_cc1" name="mail_cc1" maxlength="250" email #cc1='ngModel'>

then you can add conditional class or error

[ngClass]="{'has-success':(notificationForm.submitted || cc1.dirty) && cc1.valid,
                  'has-error': (notificationForm.submitted || cc1.dirty) && cc1.invalid}"
Ashutosh Jha
  • 15,451
  • 11
  • 52
  • 85