Creates an AbstractControl
from a user-specified configuration.
使用用户指定的配置创建 AbstractControl
。
方法
|
---|
Construct a new FormGroup instance. 构建一个新的 FormGroup 实例。 |
group(controlsConfig: { [key: string]: any; }, extra: { [key: string]: any; } | null = null): FormGroup参数controlsConfig | A collection of child controls. The key for each child is the name under which it is registered. 一组子控件。每个 key 就是注册进来的控件的名字。 | extra | An object of configuration options for the FormGroup . 一个对象,表示 FormGroup 的配置项。 validator : A synchronous validator function, or an array of validator functions
validator :一个同步验证器函数或其数组
asyncValidator : A single async validator or array of async validator functions
asyncValidator :一个异步验证器函数或其数组
可选. 默认值是 null . |
返回值FormGroup
|
|
---|
Construct a new FormControl instance. 构建一个新的 FormControl 实例。 |
control(formState: any, validator?: ValidatorFn | ValidatorFn[] | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormControl参数formState | Initializes the control with an initial value, or an object that defines the initial value and disabled state. 使用一个初始值或一个定义了初始值和禁用状态的对象初始化该控件。 | validator | A synchronous validator function, or an array of synchronous validator functions. 一个同步验证器函数或其数组。 可选. 默认值是 undefined . | asyncValidator | A single async validator or array of async validator functions 一个异步验证器函数或其数组。 可选. 默认值是 undefined . |
返回值FormControl
|
Initialize a control as disabled把控件初始化为禁用状态The following example returns a control with an initial value in a disabled state. 下面的例子返回一个带有初始值并已禁用的控件。 import {Component, Inject} from '@angular/core'; import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; /* . . . */ @Component({ selector: 'app-disabled-form-control', template: ` <input [formControl]="control" placeholder="First"> ` }) export class DisabledFormControlComponent { control: FormControl; constructor(private fb: FormBuilder) { this.control = fb.control({value: 'my val', disabled: true}); } } |
|
---|
Construct a new FormArray instance. 构造一个新的 FormArray 实例。 |
array(controlsConfig: any[], validator?: ValidatorFn | ValidatorFn[] | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null): FormArray参数controlsConfig | An array of child controls. The key for each child control is its index in the array. 一个子控件数组。每个子控件的 key 都是它在数组中的索引。 | validator | A synchronous validator function, or an array of synchronous validator functions. 一个同步验证器函数或其数组。 可选. 默认值是 undefined . | asyncValidator | A single async validator or array of async validator functions 一个异步验证器数组或其数组。 可选. 默认值是 undefined . |
返回值FormArray
|