UNPKG

angular2

Version:

Angular 2 - a web framework for modern web apps

80 lines (79 loc) 2.55 kB
import { Type } from 'angular2/src/facade/lang'; import * as modelModule from './model'; /** * Creates a form object from a user-specified configuration. * * ### Example ([live demo](http://plnkr.co/edit/ENgZo8EuIECZNensZCVr?p=preview)) * * ```typescript * @Component({ * selector: 'my-app', * viewBindings: [FORM_BINDINGS] * template: ` * <form [ng-form-model]="loginForm"> * <p>Login <input ng-control="login"></p> * <div ng-control-group="passwordRetry"> * <p>Password <input type="password" ng-control="password"></p> * <p>Confirm password <input type="password" ng-control="passwordConfirmation"></p> * </div> * </form> * <h3>Form value:</h3> * <pre>{{value}}</pre> * `, * directives: [FORM_DIRECTIVES] * }) * export class App { * loginForm: ControlGroup; * * constructor(builder: FormBuilder) { * this.loginForm = builder.group({ * login: ["", Validators.required], * passwordRetry: builder.group({ * password: ["", Validators.required], * passwordConfirmation: ["", Validators.required, asyncValidator] * }) * }); * } * * get value(): string { * return JSON.stringify(this.loginForm.value, null, 2); * } * } * ``` */ export declare class FormBuilder { /** * Construct a new {@link ControlGroup} with the given map of configuration. * Valid keys for the `extra` parameter map are `optionals` and `validator`. * * See the {@link ControlGroup} constructor for more details. */ group(controlsConfig: { [key: string]: any; }, extra?: { [key: string]: any; }): modelModule.ControlGroup; /** * Construct a new {@link Control} with the given `value`,`validator`, and `asyncValidator`. */ control(value: Object, validator?: Function, asyncValidator?: Function): modelModule.Control; /** * Construct an array of {@link Control}s from the given `controlsConfig` array of * configuration, with the given optional `validator` and `asyncValidator`. */ array(controlsConfig: any[], validator?: Function, asyncValidator?: Function): modelModule.ControlArray; } /** * Shorthand set of providers used for building Angular forms. * * ### Example * * ```typescript * bootstrap(MyApp, [FORM_PROVIDERS]); * ``` */ export declare const FORM_PROVIDERS: Type[]; /** * @deprecated */ export declare const FORM_BINDINGS: Type[];