docs(API): 翻译完了 FormBuilder
This commit is contained in:
parent
986872ecbd
commit
82ba447ca0
@ -50,7 +50,7 @@
|
|||||||
[x] | common/CurrencyPipe | 0.39
|
[x] | common/CurrencyPipe | 0.39
|
||||||
[x] | router/RouterLinkActive | 0.38
|
[x] | router/RouterLinkActive | 0.38
|
||||||
[x] | core/TemplateRef | 0.38
|
[x] | core/TemplateRef | 0.38
|
||||||
[ ] | forms/FormBuilder | 0.37
|
[x] | forms/FormBuilder | 0.37
|
||||||
[ ] | common/http/HttpParams | 0.35
|
[ ] | common/http/HttpParams | 0.35
|
||||||
[ ] | core/OnChanges | 0.35
|
[ ] | core/OnChanges | 0.35
|
||||||
[ ] | forms/FormControlName | 0.34
|
[ ] | forms/FormControlName | 0.34
|
||||||
|
@ -15,12 +15,19 @@ import {AbstractControl, FormArray, FormControl, FormGroup} from './model';
|
|||||||
* @description
|
* @description
|
||||||
* Creates an `AbstractControl` from a user-specified configuration.
|
* Creates an `AbstractControl` from a user-specified configuration.
|
||||||
*
|
*
|
||||||
|
* 使用用户指定的配置创建 `AbstractControl`。
|
||||||
|
*
|
||||||
* The `FormBuilder` provides syntactic sugar that shortens creating instances of a `FormControl`,
|
* The `FormBuilder` provides syntactic sugar that shortens creating instances of a `FormControl`,
|
||||||
* `FormGroup`, or `FormArray`. It reduces the amount of boilerplate needed to build complex
|
* `FormGroup`, or `FormArray`. It reduces the amount of boilerplate needed to build complex
|
||||||
* forms.
|
* forms.
|
||||||
*
|
*
|
||||||
|
* `FormBuilder` 提供了一个语法糖,以简化 `FormControl`、`FormGroup` 或 `FormArray` 实例的创建过程。
|
||||||
|
* 它会减少构建复杂表单时所需的样板代码的数量。
|
||||||
|
*
|
||||||
* @see [Reactive Forms Guide](/guide/reactive-forms)
|
* @see [Reactive Forms Guide](/guide/reactive-forms)
|
||||||
*
|
*
|
||||||
|
* [响应式表单](/guide/reactive-forms)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FormBuilder {
|
export class FormBuilder {
|
||||||
@ -28,13 +35,25 @@ export class FormBuilder {
|
|||||||
* @description
|
* @description
|
||||||
* Construct a new `FormGroup` instance.
|
* Construct a new `FormGroup` instance.
|
||||||
*
|
*
|
||||||
|
* 构建一个新的 `FormGroup` 实例。
|
||||||
|
*
|
||||||
* @param controlsConfig A collection of child controls. The key for each child is the name
|
* @param controlsConfig A collection of child controls. The key for each child is the name
|
||||||
* under which it is registered.
|
* under which it is registered.
|
||||||
*
|
*
|
||||||
|
* 一组子控件。每个 key 就是注册进来的控件的名字。
|
||||||
|
*
|
||||||
* @param extra An object of configuration options for the `FormGroup`.
|
* @param extra An object of configuration options for the `FormGroup`.
|
||||||
|
*
|
||||||
|
* 一个对象,表示 `FormGroup` 的配置项。
|
||||||
|
*
|
||||||
* * `validator`: A synchronous validator function, or an array of validator functions
|
* * `validator`: A synchronous validator function, or an array of validator functions
|
||||||
|
*
|
||||||
|
* `validator`:一个同步验证器函数或其数组
|
||||||
|
*
|
||||||
* * `asyncValidator`: A single async validator or array of async validator functions
|
* * `asyncValidator`: A single async validator or array of async validator functions
|
||||||
*
|
*
|
||||||
|
* `asyncValidator`:一个异步验证器函数或其数组
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any}|null = null): FormGroup {
|
group(controlsConfig: {[key: string]: any}, extra: {[key: string]: any}|null = null): FormGroup {
|
||||||
const controls = this._reduceControls(controlsConfig);
|
const controls = this._reduceControls(controlsConfig);
|
||||||
@ -47,20 +66,32 @@ export class FormBuilder {
|
|||||||
* @description
|
* @description
|
||||||
* Construct a new `FormControl` instance.
|
* Construct a new `FormControl` instance.
|
||||||
*
|
*
|
||||||
|
* 构建一个新的 `FormControl` 实例。
|
||||||
|
*
|
||||||
* @param formState Initializes the control with an initial value,
|
* @param formState Initializes the control with an initial value,
|
||||||
* or an object that defines the initial value and disabled state.
|
* or an object that defines the initial value and disabled state.
|
||||||
*
|
*
|
||||||
|
* 使用一个初始值或一个定义了初始值和禁用状态的对象初始化该控件。
|
||||||
|
*
|
||||||
* @param validator A synchronous validator function, or an array of synchronous validator
|
* @param validator A synchronous validator function, or an array of synchronous validator
|
||||||
* functions.
|
* functions.
|
||||||
*
|
*
|
||||||
|
* 一个同步验证器函数或其数组。
|
||||||
|
*
|
||||||
* @param asyncValidator A single async validator or array of async validator functions
|
* @param asyncValidator A single async validator or array of async validator functions
|
||||||
*
|
*
|
||||||
|
* 一个异步验证器函数或其数组。
|
||||||
|
*
|
||||||
* @usageNotes
|
* @usageNotes
|
||||||
*
|
*
|
||||||
* ### Initialize a control as disabled
|
* ### Initialize a control as disabled
|
||||||
*
|
*
|
||||||
|
* ### 把控件初始化为禁用状态
|
||||||
|
*
|
||||||
* The following example returns a control with an initial value in a disabled state.
|
* The following example returns a control with an initial value in a disabled state.
|
||||||
*
|
*
|
||||||
|
* 下面的例子返回一个带有初始值并已禁用的控件。
|
||||||
|
*
|
||||||
* <code-example path="forms/ts/formBuilder/form_builder_example.ts"
|
* <code-example path="forms/ts/formBuilder/form_builder_example.ts"
|
||||||
* linenums="false" region="disabled-control">
|
* linenums="false" region="disabled-control">
|
||||||
* </code-example>
|
* </code-example>
|
||||||
@ -76,13 +107,22 @@ export class FormBuilder {
|
|||||||
* @description
|
* @description
|
||||||
* Construct a new `FormArray` instance.
|
* Construct a new `FormArray` instance.
|
||||||
*
|
*
|
||||||
|
* 构造一个新的 `FormArray` 实例。
|
||||||
|
*
|
||||||
* @param controlsConfig An array of child controls. The key for each child control is its index
|
* @param controlsConfig An array of child controls. The key for each child control is its index
|
||||||
* in the array.
|
* in the array.
|
||||||
*
|
*
|
||||||
|
* 一个子控件数组。每个子控件的 key 都是它在数组中的索引。
|
||||||
|
*
|
||||||
* @param validator A synchronous validator function, or an array of synchronous validator
|
* @param validator A synchronous validator function, or an array of synchronous validator
|
||||||
* functions.
|
* functions.
|
||||||
*
|
*
|
||||||
|
* 一个同步验证器函数或其数组。
|
||||||
|
*
|
||||||
* @param asyncValidator A single async validator or array of async validator functions
|
* @param asyncValidator A single async validator or array of async validator functions
|
||||||
|
*
|
||||||
|
* 一个异步验证器数组或其数组。
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
array(
|
array(
|
||||||
controlsConfig: any[], validator?: ValidatorFn|ValidatorFn[]|null,
|
controlsConfig: any[], validator?: ValidatorFn|ValidatorFn[]|null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user