EmailValidator
该指令会借助 NG_VALIDATORS
绑定把 email
验证器添加到任何带有 email
属性的控件上。
A directive that adds the email
validator to controls marked with the email
attribute. The directive is provided with the NG_VALIDATORS
multi-provider list.
参见
Exported from
选择器
[email][formControlName]
[email][formControl]
[email][ngModel]
属性
属性 | 说明 |
---|---|
@Input() | 只写 跟踪绑定到该指令的 email 属性的更改。 Tracks changes to the email attribute bound to this directive. |
说明
添加 email 验证器
Adding an email validator
下面的例子演示了如何为一个带有 ngModel 绑定的输入框添加 email 验证器。
The following example shows how to add an email validator to an input attached to an ngModel* binding.
<input type="email" name="email" ngModel email>
<input type="email" name="email" ngModel email="true">
<input type="email" name="email" ngModel [email]="true">