Add full example to FormBuilder docs

This commit is contained in:
John Jelinek IV 2015-04-29 10:33:20 -05:00 committed by Victor Berchet
parent 4ce0d5e024
commit d2507ac760
1 changed files with 44 additions and 1 deletions

View File

@ -8,8 +8,51 @@ import * as modelModule from './model';
*
* # Example
*
* ```
* import {Component, View, bootstrap} from 'angular2/angular2';
* import {FormBuilder, Validators, FormDirectives, ControlGroup} from 'angular2/forms';
*
* @Component({
* selector: 'login-comp',
* injectables: [
* FormBuilder
* ]
* })
* @View({
* template: `
* <form [control-group]="loginForm">
* Login <input control="login">
*
* <div control-group="passwordRetry">
* Password <input type="password" control="password">
* Confirm password <input type="password" control="passwordConfirmation">
* </div>
* </form>
* `,
* directives: [
* FormDirectives
* ]
* })
* class LoginComp {
* loginForm: ControlGroup;
*
* constructor(builder: FormBuilder) {
* this.loginForm = builder.group({
* login: ["", Validators.required],
*
* passwordRetry: builder.group({
* password: ["", Validators.required],
* passwordConfirmation: ["", Validators.required]
* })
* });
* }
* }
*
* bootstrap(LoginComp)
* ```
*
* This example creates a {@link ControlGroup} that consists of a `login` {@link Control}, and a nested
* {@link ControlGroup} that defines a `password` and a `passwordConfirmation` {@link Control}.
* {@link ControlGroup} that defines a `password` and a `passwordConfirmation` {@link Control}:
*
* ```
* var loginForm = builder.group({