angular-docs-cn/public/docs/js/latest/api/forms/ControlGroupDirective-class.jade

121 lines
2.0 KiB
Plaintext
Raw Normal View History

2015-04-19 13:53:18 -07:00
2015-04-22 08:06:51 -07:00
p.location-badge.
2015-06-01 22:51:00 -07:00
exported from <a href='../forms'>angular2/forms</a>
defined in <a href="https://github.com/angular/angular/tree/master/modules/angular2/src/forms/directives/control_group_directive.ts#L10-L73">angular2/src/forms/directives/control_group_directive.ts (line 10)</a>
2015-04-19 13:53:18 -07:00
:markdown
Binds a control group to a DOM element.
# Example
2015-06-01 22:51:00 -07:00
In this example, we bind the control group to the form element, and we bind the login and
password controls to the
2015-04-19 13:53:18 -07:00
login and password elements.
2015-06-01 22:51:00 -07:00
Here we use <a href='formDirectives-const.html'><code>formDirectives</code></a>, rather than importing each form directive individually, e.g.
2015-04-19 13:53:18 -07:00
`ControlDirective`, `ControlGroupDirective`. This is just a shorthand for the same end result.
```
@Component({selector: "login-comp"})
@View({
2015-06-01 22:51:00 -07:00
directives: [formDirectives],
template: "<form [control-group]='loginForm'>" +
2015-04-19 13:53:18 -07:00
"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-06-01 22:51:00 -07:00
constructor(@Ancestor() _parent: ControlContainerDirective)
2015-04-19 13:53:18 -07:00
:markdown
2015-06-01 22:51:00 -07:00
2015-04-19 13:53:18 -07:00
.l-sub-section
2015-06-01 22:51:00 -07:00
h3 formDirective
2015-04-19 13:53:18 -07:00
:markdown
2015-04-19 13:53:18 -07:00
2015-06-01 22:51:00 -07:00
2015-04-19 13:53:18 -07:00
.l-sub-section
2015-06-01 22:51:00 -07:00
h3 onDestroy
2015-04-19 13:53:18 -07:00
pre.prettyprint
code.
2015-06-01 22:51:00 -07:00
onDestroy()
2015-04-19 13:53:18 -07:00
:markdown
2015-04-19 13:53:18 -07:00
2015-06-01 22:51:00 -07:00
2015-04-19 13:53:18 -07:00
.l-sub-section
2015-06-01 22:51:00 -07:00
h3 onInit
2015-04-19 13:53:18 -07:00
pre.prettyprint
code.
2015-06-01 22:51:00 -07:00
onInit()
2015-04-19 13:53:18 -07:00
:markdown
2015-04-19 13:53:18 -07:00
2015-06-01 22:51:00 -07:00
.l-sub-section
h3 path
:markdown
2015-04-19 13:53:18 -07:00