docs(forms): add radio button examples (#11676)

This commit is contained in:
Kara
2016-09-19 10:41:20 -07:00
committed by Alex Eagle
parent 5bf08b886f
commit fa4723a208
9 changed files with 222 additions and 19 deletions
@@ -59,21 +59,33 @@ export class RadioControlRegistry {
}
/**
* The accessor for writing a radio control value and listening to changes that is used by the
* {@link NgModel}, {@link FormControlDirective}, and {@link FormControlName} directives.
* @whatItDoes Writes radio control values and listens to radio control changes.
*
* ### Example
* ```
* @Component({
* template: `
* <input type="radio" name="food" [(ngModel)]="food" value="chicken">
* <input type="radio" name="food" [(ngModel)]="food" value="fish">
* `
* })
* class FoodCmp {
* food = 'chicken';
* }
* ```
* Used by {@link NgModel}, {@link FormControlDirective}, and {@link FormControlName}
* to keep the view synced with the {@link FormControl} model.
*
* @howToUse
*
* If you have imported the {@link FormsModule} or the {@link ReactiveFormsModule}, this
* value accessor will be active on any radio control that has a form directive. You do
* **not** need to add a special selector to activate it.
*
* ### How to use radio buttons with form directives
*
* To use radio buttons in a template-driven form, you'll want to ensure that radio buttons
* in the same group have the same `name` attribute. Radio buttons with different `name`
* attributes do not affect each other.
*
* {@example forms/ts/radioButtons/radio_button_example.ts region='TemplateDriven'}
*
* When using radio buttons in a reactive form, radio buttons in the same group should have the
* same `formControlName`. You can also add a `name` attribute, but it's optional.
*
* {@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
*
* * **npm package**: `@angular/forms`
*
* @stable
*/
@Directive({
selector: