RequiredValidator
该指令会借助 NG_VALIDATORS
绑定把 required
验证器添加到任何带 required
属性的控件上。
A directive that adds the required
validator to any controls marked with the required
attribute. The directive is provided with the NG_VALIDATORS
multi-provider list.
参见
NgModules
选择器
:not([type=checkbox])[required][formControlName]
:not([type=checkbox])[required][formControl]
:not([type=checkbox])[required][ngModel]
属性
属性 | 说明 |
---|---|
@Input() | Tracks changes to the required attribute bound to this directive. |
说明
使用模板驱动表单添加必填项验证器
Adding a required validator using template-driven forms
<input name="fullName" ngModel required>
方法
Method that validates whether the control is empty. Returns the validation result if enabled, otherwise null. | |||
参数
返回值
|
Registers a callback function to call when the validator inputs change. |