<input type ="email" name="myEmail">
在anuglar 1中
有错误,可能会像这样的东西
(myForm.myEmail.$error.email
)如果电子邮件ID不正确
但它不是Angular 2的情况,如何在角度2中验证它?
答案 0 :(得分:1)
<input type="text" class="form-control" placeholder="Enter Email" [(ngModel)]="notificaion.mail_cc1" name="mail_cc1" maxlength="250" email #cc1='ngModel'>
然后你可以添加条件类或错误
[ngClass]="{'has-success':(notificationForm.submitted || cc1.dirty) && cc1.valid,
'has-error': (notificationForm.submitted || cc1.dirty) && cc1.invalid}"