docs: improve DefaultValueAccessor directive docs (#39404)

This commit improves the DefaultValueAccessor directive docs by:
- adding the `ngDefaultControl` as a search keyword to the description
- adding an example of the `ngDefaultControl` usage

Closes #35375.

PR Close #39404
This commit is contained in:
Andrew Kushnir 2020-10-23 13:09:11 -07:00 committed by Alex Rickabaugh
parent cf60e0e889
commit 1db4f212e5
1 changed files with 12 additions and 0 deletions

View File

@ -36,6 +36,9 @@ export const COMPOSITION_BUFFER_MODE = new InjectionToken<boolean>('CompositionE
/** /**
* @description * @description
*
* {@searchKeywords ngDefaultControl}
*
* The default `ControlValueAccessor` for writing a value and listening to changes on input * The default `ControlValueAccessor` for writing a value and listening to changes on input
* elements. The accessor is used by the `FormControlDirective`, `FormControlName`, and * elements. The accessor is used by the `FormControlDirective`, `FormControlName`, and
* `NgModel` directives. * `NgModel` directives.
@ -55,6 +58,15 @@ export const COMPOSITION_BUFFER_MODE = new InjectionToken<boolean>('CompositionE
* <input type="text" [formControl]="firstNameControl"> * <input type="text" [formControl]="firstNameControl">
* ``` * ```
* *
* This value accessor is used by default for `<input type="text">` and `<textarea>` elements, but
* you could also use it for custom components that have similar behavior and do not require special
* processing. In order to attach the default value accessor to a custom element, add the
* `ngDefaultControl` attribute as shown below.
*
* ```
* <custom-input-component ngDefaultControl [(ngModel)]="value"></custom-input-component>
* ```
*
* @ngModule ReactiveFormsModule * @ngModule ReactiveFormsModule
* @ngModule FormsModule * @ngModule FormsModule
* @publicApi * @publicApi