Creates a form object from a user-specified configuration.

@Component(
  selector: 'my-app',
  viewBindings: const [FORM_BINDINGS]
  template: '''
    <form [ngFormModel]="loginForm">
      <p>Login <input ngControl="login"></p>
      <div ngControlGroup="passwordRetry">
        <p>Password <input type="password" ngControl="password"></p>
        <p>Confirm password <input type="password"
           ngControl="passwordConfirmation"></p>
      </div>
    </form>
    <h3>Form value:</h3>
    <pre>{{value}}</pre>
  ''',
  directives: const [FORM_DIRECTIVES]
)
class App {
  ControlGroup loginForm;
 
  App(FormBuilder builder) {
    this.loginForm = builder.group({
      "login": ["", Validators.required],
      "passwordRetry": builder.group({
        "password": ["", Validators.required],
        "passwordConfirmation": ["", Validators.required, asyncValidator]
      })
    });
  }
 
  String get value {
    return JSON.encode(this.loginForm.value);
  }
}
Annotations

Constructors

FormBuilder()

Properties

hashCode → int

Get a hash code for this object.

read-only, inherited
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

array(List controlsConfig, [ ValidatorFn validator = null, AsyncValidatorFn asyncValidator = null ]) ControlArray

Construct an array of Controls from the given controlsConfig array of configuration, with the given optional validator and asyncValidator.

control(Object value, [ ValidatorFn validator = null, AsyncValidatorFn asyncValidator = null ]) Control

Construct a new Control with the given value, validator, and asyncValidator.

group(Map<String, dynamic> controlsConfig, [ Map<String, dynamic> extra = null ]) ControlGroup

Construct a new ControlGroup with the given map of configuration. Valid keys for the extra parameter map are optionals and validator.

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
toString() → String

Returns a string representation of this object.

inherited