FormsModule

Exports the required providers and directives for template-driven forms, making them available for import by NgModules that import this module.

导出模板驱动表单所需的提供商和指令,使其可用于导入了该模块的 NgModule 中。

class FormsModule { static withConfig(opts: {...}): ModuleWithProviders<FormsModule> }

参见

Static methods

Provides options for configuring the template-driven forms module.

static withConfig(opts: { warnOnDeprecatedNgFormSelector?: 'never' | 'once' | 'always'; }): ModuleWithProviders<FormsModule>

参数

opts

An object of configuration options

  • warnOnDeprecatedNgFormSelector Configures when to emit a warning when the deprecated ngForm selector is used.

返回值

ModuleWithProviders<FormsModule>

Providers

Provider
RadioControlRegistry

Directives

NameDescription
CheckboxControlValueAccessor

The accessor for writing a value and listening to changes on a checkbox input element.

CheckboxRequiredValidator

A Directive that adds the required validator to checkbox controls marked with the required attribute, via the NG_VALIDATORS binding.

该指令会借助 NG_VALIDATORS 绑定把 required 验证器添加到任何带有 required 属性的检查框控件上。

DefaultValueAccessor

The default accessor for writing a value and listening to changes that is used by the NgModel, FormControlDirective, and FormControlName directives.

EmailValidator

A Directive that adds the email validator to controls marked with the email attribute, via the NG_VALIDATORS binding.

该指令会借助 NG_VALIDATORS 绑定把 email 验证器添加到任何带有 email 属性的控件上。

MaxLengthValidator

A directive which installs the MaxLengthValidator for any formControlName, formControl, or control with ngModel that also has a maxlength attribute.

MinLengthValidator

A directive which installs the MinLengthValidator for any formControlName, formControl, or control with ngModel that also has a minlength attribute.

NgControlStatus

Directive automatically applied to Angular form controls that sets CSS classes based on control status. The following classes are applied as the properties become true:

NgControlStatusGroup

Directive automatically applied to Angular form groups that sets CSS classes based on control status (valid/invalid/dirty/etc).

NgForm

Creates a top-level FormGroup instance and binds it to a form to track aggregate form value and validation status.

创建一个顶级的 FormGroup 实例,并把它绑定到一个表单,以跟踪表单的聚合值及其验证状态。

NgFormSelectorWarning

Deprecated: in Angular v6 and will be removed in Angular v9.

This directive is solely used to display warnings when the deprecated ngForm selector is used.

NgModel

Creates a FormControl instance from a domain model and binds it to a form control element.

根据领域对象创建一个 FormControl 实例,并把它绑定到一个表单控件元素上。

NgModelGroup

Creates and binds a FormGroup instance to a DOM element.

NgSelectOption

Marks <option> as dynamic, so Angular can be notified when options change.

把选项 <option> 标记为动态的,这样 Angular 就会在选项变化时得到通知。

PatternValidator

A Directive that adds the pattern validator to any controls marked with the pattern attribute, via the NG_VALIDATORS binding. Uses attribute value as the regex to validate Control value against. Follows pattern attribute semantics; i.e. regex must match entire Control value.

该指令会借助 NG_VALIDATORS 绑定来把 pattern 验证器添加到任何带有 pattern 属性的控件上。 它会使用该属性的值作为正则表达式来验证控件的值。 它会遵循 pattern 属性的语义,也就是说,该正则表达式必须匹配整个控件值。

RadioControlValueAccessor

Writes radio control values and listens to radio control changes.

RequiredValidator

A Directive that adds the required validator to any controls marked with the required attribute, via the NG_VALIDATORS binding.

该指令会借助 NG_VALIDATORS 绑定把 required 验证器添加到任何带 required 属性的控件上。

SelectControlValueAccessor

Writes values and listens to changes on a select element.

select 元素上写入值并监听其变更。

SelectMultipleControlValueAccessor

The accessor for writing a value and listening to changes on a select element.