From d2507ac76087c3dca635fe954b90a3aab7c37b04 Mon Sep 17 00:00:00 2001 From: John Jelinek IV Date: Wed, 29 Apr 2015 10:33:20 -0500 Subject: [PATCH] Add full example to FormBuilder docs --- modules/angular2/src/forms/form_builder.js | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/forms/form_builder.js b/modules/angular2/src/forms/form_builder.js index 20e6808aec..3c745166cc 100644 --- a/modules/angular2/src/forms/form_builder.js +++ b/modules/angular2/src/forms/form_builder.js @@ -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: ` + *
+ * Login + * + *
+ * Password + * Confirm password + *
+ *
+ * `, + * 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({