Add full example to FormBuilder docs
This commit is contained in:
parent
4ce0d5e024
commit
d2507ac760
|
@ -8,8 +8,51 @@ import * as modelModule from './model';
|
||||||
*
|
*
|
||||||
* # Example
|
* # 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
|
* 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({
|
* var loginForm = builder.group({
|
||||||
|
|
Loading…
Reference in New Issue