feat(forms): renamed control, control-group into ng-control and ng-control-group
This commit is contained in:
@ -9,14 +9,14 @@ import {ControlValueAccessor} from './control_value_accessor';
|
||||
*
|
||||
* # Example
|
||||
* ```
|
||||
* <input type="checkbox" [control]="rememberLogin">
|
||||
* <input type="checkbox" [ng-control]="rememberLogin">
|
||||
* ```
|
||||
*
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector:
|
||||
'input[type=checkbox][control],input[type=checkbox][form-control],input[type=checkbox][ng-model]',
|
||||
'input[type=checkbox][ng-control],input[type=checkbox][ng-form-control],input[type=checkbox][ng-model]',
|
||||
hostListeners: {'change': 'onChange($event.target.checked)'},
|
||||
hostProperties: {'checked': 'checked'}
|
||||
})
|
||||
|
@ -2,7 +2,7 @@ import {ControlValueAccessor} from './control_value_accessor';
|
||||
import {Validators} from '../validators';
|
||||
|
||||
/**
|
||||
* A directive that bind a [Control] object to a DOM element.
|
||||
* A directive that bind a [ng-control] object to a DOM element.
|
||||
*
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
|
@ -10,11 +10,11 @@ const controlGroupBinding = CONST_EXPR(
|
||||
new Binding(ControlContainerDirective, {toAlias: FORWARD_REF(() => ControlGroupDirective)}));
|
||||
|
||||
/**
|
||||
* Binds a control group to a DOM element.
|
||||
* Binds a ng-control group to a DOM element.
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* In this example, we create a control group, and we bind the login and
|
||||
* In this example, we create a ng-control group, and we bind the login and
|
||||
* password controls to the login and password elements.
|
||||
*
|
||||
* Here we use {@link formDirectives}, rather than importing each form directive individually, e.g.
|
||||
@ -25,10 +25,10 @@ const controlGroupBinding = CONST_EXPR(
|
||||
* @View({
|
||||
* directives: [formDirectives],
|
||||
* template:
|
||||
* "<form [form-model]='loginForm'>" +
|
||||
* "<div control-group="credentials">
|
||||
* "Login <input type='text' control='login'>" +
|
||||
* "Password <input type='password' control='password'>" +
|
||||
* "<form [ng-form-model]='loginForm'>" +
|
||||
* "<div ng-control-group="credentials">
|
||||
* "Login <input type='text' ng-control='login'>" +
|
||||
* "Password <input type='password' ng-control='password'>" +
|
||||
* "<button (click)="onLogin()">Login</button>" +
|
||||
* "</div>"
|
||||
* "</form>"
|
||||
@ -39,7 +39,7 @@ const controlGroupBinding = CONST_EXPR(
|
||||
* constructor() {
|
||||
* this.loginForm = new ControlGroup({
|
||||
* credentials: new ControlGroup({
|
||||
* login: new Control(""),
|
||||
* login: new Cntrol(""),
|
||||
* password: new Control("")
|
||||
* })
|
||||
* });
|
||||
@ -55,9 +55,9 @@ const controlGroupBinding = CONST_EXPR(
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[control-group]',
|
||||
selector: '[ng-control-group]',
|
||||
hostInjector: [controlGroupBinding],
|
||||
properties: ['name: control-group'],
|
||||
properties: ['name: ng-control-group'],
|
||||
lifecycle: [onInit, onDestroy]
|
||||
})
|
||||
export class ControlGroupDirective extends ControlContainerDirective {
|
||||
|
@ -31,8 +31,8 @@ const controlNameBinding =
|
||||
* @View({
|
||||
* directives: [formDirectives],
|
||||
* template:
|
||||
* "<form [form-model]='loginForm'>" +
|
||||
* "Login <input type='text' control='login'>" +
|
||||
* "<form [ng-form-model]='loginForm'>" +
|
||||
* "Login <input type='text' ng-control='login'>" +
|
||||
* "<button (click)="onLogin()">Login</button>" +
|
||||
* "</form>"
|
||||
* })
|
||||
@ -55,9 +55,9 @@ const controlNameBinding =
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[control]',
|
||||
selector: '[ng-control]',
|
||||
hostInjector: [controlNameBinding],
|
||||
properties: ['name: control', 'model: ng-model'],
|
||||
properties: ['name: ng-control', 'model: ng-model'],
|
||||
events: ['ngModel'],
|
||||
lifecycle: [onDestroy, onChange]
|
||||
})
|
||||
|
@ -11,15 +11,14 @@ import {ControlValueAccessor} from './control_value_accessor';
|
||||
*
|
||||
* # Example
|
||||
* ```
|
||||
* <input type="text" [form-control]="loginControl">
|
||||
* <input type="text" [ng-form-control]="loginControl">
|
||||
* ```
|
||||
*
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'input:not([type=checkbox])[control],textarea[control],' +
|
||||
'input:not([type=checkbox])[form-control],textarea[form-control],' +
|
||||
'input:not([type=checkbox])[ng-model],textarea[ng-model]',
|
||||
selector:
|
||||
'input:not([type=checkbox])[ng-control],textarea[ng-control],input:not([type=checkbox])[ng-form-control],textarea[ng-form-control],input:not([type=checkbox])[ng-model],textarea[ng-model]',
|
||||
hostListeners:
|
||||
{'change': 'onChange($event.target.value)', 'input': 'onChange($event.target.value)'},
|
||||
hostProperties: {'value': 'value'}
|
||||
|
@ -30,7 +30,7 @@ const formControlBinding =
|
||||
* @Component({selector: "login-comp"})
|
||||
* @View({
|
||||
* directives: [formDirectives],
|
||||
* template: "<input type='text' [form-control]='loginControl'>"
|
||||
* template: "<input type='text' [ng-form-control]='loginControl'>"
|
||||
* })
|
||||
* class LoginComp {
|
||||
* loginControl:Control;
|
||||
@ -45,9 +45,9 @@ const formControlBinding =
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[form-control]',
|
||||
selector: '[ng-form-control]',
|
||||
hostInjector: [formControlBinding],
|
||||
properties: ['control: form-control', 'model: ng-model'],
|
||||
properties: ['control: ng-form-control', 'model: ng-model'],
|
||||
events: ['ngModel'],
|
||||
lifecycle: [onChange]
|
||||
})
|
||||
|
@ -28,9 +28,9 @@ const formDirectiveBinding = CONST_EXPR(
|
||||
* @Component({selector: "login-comp"})
|
||||
* @View({
|
||||
* directives: [formDirectives],
|
||||
* template: "<form [form-model]='loginForm'>" +
|
||||
* "Login <input type='text' control='login'>" +
|
||||
* "Password <input type='password' control='password'>" +
|
||||
* template: "<form [ng-form-model]='loginForm'>" +
|
||||
* "Login <input type='text' ng-control='login'>" +
|
||||
* "Password <input type='password' ng-control='password'>" +
|
||||
* "<button (click)="onLogin()">Login</button>" +
|
||||
* "</form>"
|
||||
* })
|
||||
@ -54,9 +54,9 @@ const formDirectiveBinding = CONST_EXPR(
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[form-model]',
|
||||
selector: '[ng-form-model]',
|
||||
hostInjector: [formDirectiveBinding],
|
||||
properties: ['form: form-model'],
|
||||
properties: ['form: ng-form-model'],
|
||||
lifecycle: [onChange]
|
||||
})
|
||||
export class FormModelDirective extends ControlContainerDirective implements FormDirective {
|
||||
|
@ -13,7 +13,7 @@ const formControlBinding =
|
||||
CONST_EXPR(new Binding(ControlDirective, {toAlias: FORWARD_REF(() => NgModelDirective)}));
|
||||
|
||||
@Directive({
|
||||
selector: '[ng-model]:not([control]):not([form-control])',
|
||||
selector: '[ng-model]:not([ng-control]):not([ng-form-control])',
|
||||
hostInjector: [formControlBinding],
|
||||
properties: ['model: ng-model'],
|
||||
events: ['ngModel'],
|
||||
|
@ -11,13 +11,13 @@ import {ControlValueAccessor} from './control_value_accessor';
|
||||
*
|
||||
* # Example
|
||||
* ```
|
||||
* <input type="text" [control]="loginControl">
|
||||
* <input type="text" [ng-control]="loginControl">
|
||||
* ```
|
||||
*
|
||||
* @exportedAs angular2/forms
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'select[control],select[form-control],select[ng-model]',
|
||||
selector: 'select[ng-control],select[ng-form-control],select[ng-model]',
|
||||
hostListeners:
|
||||
{'change': 'onChange($event.target.value)', 'input': 'onChange($event.target.value)'},
|
||||
hostProperties: {'value': 'value'}
|
||||
|
@ -14,7 +14,7 @@ const formDirectiveBinding = CONST_EXPR(new Binding(
|
||||
ControlContainerDirective, {toAlias: FORWARD_REF(() => TemplateDrivenFormDirective)}));
|
||||
|
||||
@Directive({
|
||||
selector: 'form:not([ng-no-form]):not([form-model]),ng-form,[ng-form]',
|
||||
selector: 'form:not([ng-no-form]):not([ng-form-model]),ng-form,[ng-form]',
|
||||
hostInjector: [formDirectiveBinding]
|
||||
})
|
||||
export class TemplateDrivenFormDirective extends ControlContainerDirective implements
|
||||
|
Reference in New Issue
Block a user