type =" email"角度2有效吗?

时间:2016-09-30 11:20:31

标签: angular

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

在anuglar 1中  有错误,可能会像这样的东西 (myForm.myEmail.$error.email)如果电子邮件ID不正确 但它不是Angular 2的情况,如何在角度2中验证它?

1 个答案:

答案 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}"