2015-04-19 16:53:18 -04:00
2015-04-22 11:06:51 -04:00
p.location-badge.
2015-04-23 11:27:36 -04:00
exported from <a href="/angular2/forms.html">angular2/forms</a>
2015-04-19 16:53:18 -04:00
defined in <a href="https://github.com/angular/angular/tree/master/modules/angular2/src/forms/directives.js#L210">angular2/src/forms/directives.js (line 210)</a>
:markdown
Binds a control group to a DOM element.
# Example
In this example, we bind the control group to the form element, and we bind the login and password controls to the
login and password elements.
2015-04-26 11:01:04 -04:00
Here we use <a href='FormDirectives-var.html'><code>FormDirectives</code></a>, rather than importing each form directive individually, e.g.
2015-04-19 16:53:18 -04:00
`ControlDirective`, `ControlGroupDirective`. This is just a shorthand for the same end result.
```
@Component({selector: "login-comp"})
@View({
directives: [FormDirectives],
inline: "<form [control-group]='loginForm'>" +
"Login <input type='text' control='login'>" +
"Password <input type='password' control='password'>" +
"<button (click)="onLogin()">Login</button>" +
"</form>"
})
class LoginComp {
loginForm:ControlGroup;
constructor() {
this.loginForm = new ControlGroup({
login: new Control(""),
password: new Control("")
});
}
onLogin() {
// this.loginForm.value
}
}
```
.l-main-section
h2 Members
.l-sub-section
h3 constructor
pre.prettyprint
code.
2015-04-20 16:57:43 -04:00
constructor(groupDirective:ControlGroupDirective)
2015-04-19 16:53:18 -04:00
:markdown
.l-sub-section
h3 addDirective
pre.prettyprint
code.
2015-04-20 16:57:43 -04:00
addDirective(c:ControlDirective)
2015-04-19 16:53:18 -04:00
:markdown
.l-sub-section
h3 controlGroup
pre.prettyprint
code.
2015-04-20 16:57:43 -04:00
controlGroup(controlGroup)
2015-04-19 16:53:18 -04:00
:markdown
.l-sub-section
h3 findControl
pre.prettyprint
code.
2015-04-20 16:57:43 -04:00
findControl(name:string)
2015-04-19 16:53:18 -04:00
:markdown