docs(API): 翻译完了 FormControlName

This commit is contained in:
Zhicheng Wang 2018-09-04 13:21:25 +08:00
parent 201976fd31
commit c3ec312159
2 changed files with 67 additions and 1 deletions

View File

@ -53,7 +53,7 @@
[x] | forms/FormBuilder | 0.37
[x] | common/http/HttpParams | 0.35
[x] | core/OnChanges | 0.35
[ ] | forms/FormControlName | 0.34
[x] | forms/FormControlName | 0.34
[x] | core/Output | 0.33
[ ] | common/http/HttpInterceptor | 0.30
[ ] | common/http/HttpRequest | 0.29

View File

@ -33,55 +33,96 @@ export const controlNameBinding: any = {
* Syncs a `FormControl` in an existing `FormGroup` to a form control
* element by name.
*
* `FormGroup` `FormControl`
*
* This directive ensures that any values written to the `FormControl`
* instance programmatically will be written to the DOM element (model -> view). Conversely,
* any values written to the DOM element through user input will be reflected in the
* `FormControl` instance (view -> model).
*
* `FormControl` DOM ->
* DOM `FormControl` ->
*
* This directive is designed to be used with a parent `FormGroupDirective` (selector:
* `[formGroup]`).
*
* `FormGroupDirective``[formGroup]`使
*
* It accepts the string name of the `FormControl` instance you want to
* link, and will look for a `FormControl` registered with that name in the
* closest `FormGroup` or `FormArray` above it.
*
* `FormControl` `FormGroup``FormArray` `FormControl`
*
* **Access the control**: You can access the `FormControl` associated with
* this directive by using the {@link AbstractControl#get get} method.
* Ex: `this.form.get('first');`
*
* **访**使 {@link AbstractControl#get get} 访`FormControl`
* `this.form.get('first');`
*
* **Get value**: the `value` property is always synced and available on the `FormControl`.
* See a full list of available properties in `AbstractControl`.
*
* **** `value` `FormControl`
* `AbstractControl`
*
* **Set value**: You can set an initial value for the control when instantiating the
* `FormControl`, or you can set it programmatically later using
* {@link AbstractControl#setValue setValue} or {@link AbstractControl#patchValue patchValue}.
*
* **** `FormControl`
* 使 {@link AbstractControl#setValue setValue} {@link AbstractControl#patchValue patchValue}
*
* **Listen to value**: If you want to listen to changes in the value of the control, you can
* subscribe to the {@link AbstractControl#valueChanges valueChanges} event. You can also listen to
* {@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
* re-calculated.
*
* **** {@link AbstractControl#valueChanges valueChanges}
* {@link AbstractControl#statusChanges statusChanges} 便
*
* ### Example
*
* ###
*
* In this example, we create form controls for first name and last name.
*
*
*
* {@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
*
* To see `formControlName` examples with different form control types, see:
*
* `formControlName`
*
* * Radio buttons: `RadioControlValueAccessor`
*
* : `RadioControlValueAccessor`
*
* * Selects: `SelectControlValueAccessor`
*
* : `SelectControlValueAccessor`
*
* **npm package**: `@angular/forms`
*
* **npm **: `@angular/forms`
*
* **NgModule**: `ReactiveFormsModule`
*
* ### Use with ngModel
*
* ### ngModel 使
*
* Support for using the `ngModel` input property and `ngModelChange` event with reactive
* form directives has been deprecated in Angular v6 and will be removed in Angular v7.
*
* Angular v6 使使 `ngModel` `ngModelChange` Angular v7
*
* Now deprecated:
*
*
*
* ```html
* <form [formGroup]="form">
* <input formControlName="first" [(ngModel)]="value">
@ -100,18 +141,33 @@ export const controlNameBinding: any = {
* delaying updates with`ngModelOptions` or exporting the directive - simply don't work,
* which has understandably caused some confusion.
*
*
* 使 `ngModel`
* `ngModel` / `ngModel`
* /
* `ngModel` - `ngModelOptions`
*
*
* In addition, this pattern mixes template-driven and reactive forms strategies, which
* we generally don't recommend because it doesn't take advantage of the full benefits of
* either strategy. Setting the value in the template violates the template-agnostic
* principles behind reactive forms, whereas adding a `FormControl`/`FormGroup` layer in
* the class removes the convenience of defining forms in the template.
*
*
* "模板无关性" `FormControl`/`FormGroup` 便
*
*
* To update your code before v7, you'll want to decide whether to stick with reactive form
* directives (and get/set values using reactive forms patterns) or switch over to
* template-driven directives.
*
* Angular v7 /
*
* After (choice 1 - use reactive forms):
*
* 1 - 使
*
* ```html
* <form [formGroup]="form">
* <input formControlName="first">
@ -124,6 +180,8 @@ export const controlNameBinding: any = {
*
* After (choice 2 - use template-driven forms):
*
* 2 - 使
*
* ```html
* <input [(ngModel)]="value">
* ```
@ -136,6 +194,9 @@ export const controlNameBinding: any = {
* mode. You can choose to silence this warning by providing a config for
* `ReactiveFormsModule` at import time:
*
* 使deprecation
* `ReactiveFormsModule`
*
* ```ts
* imports: [
* ReactiveFormsModule.withConfig({warnOnNgModelWithFormControl: 'never'});
@ -146,6 +207,8 @@ export const controlNameBinding: any = {
* pattern with a config value of `"always"`. This may help to track down where in the code
* the pattern is being used as the code is being updated.
*
* `"always"`
*
*
*/
@Directive({selector: '[formControlName]', providers: [controlNameBinding]})
@ -174,6 +237,8 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
* Static property used to track whether any ngModel warnings have been sent across
* all instances of FormControlName. Used to support warning config of "once".
*
* `FormControlName` ngModel `"once"`
*
* @internal
*/
static _ngModelWarningSentOnce = false;
@ -182,6 +247,7 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
* Instance property used to track whether an ngModel warning has been sent out for this
* particular FormControlName instance. Used to support warning config of "always".
*
* `FormControlName` ngModel `"always"`
* @internal
*/
_ngModelWarningSent = false;