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.
参见
NgModules
选择器
[email][formControlName]
[email][formControl]
[email][ngModel]
属性
属性 | 说明 |
---|---|
@Input() | Write-only. 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">
方法
Method that validates whether an email address is valid. Returns the validation result if enabled, otherwise null. | |||
参数
返回值
|
Registers a callback function to call when the validator inputs change. |