X Tutup
Skip to content

Commit 8657ca4

Browse files
committed
fix(form): Form directives are exportedAs 'ngForm' (was 'form')
fixes angular#5658 BREAKING CHANGE: Before: <form #f="form"> After: <form #f="ngForm"> Closes angular#5709
1 parent 80b025a commit 8657ca4

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

modules/angular2/src/common/forms/directives/ng_control_group.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const controlGroupProvider =
3737
* template: `
3838
* <div>
3939
* <h2>Angular2 Control &amp; ControlGroup Example</h2>
40-
* <form #f="form">
41-
* <div ng-control-group="name" #cg-name="form">
40+
* <form #f="ngForm">
41+
* <div ng-control-group="name" #cg-name="ngForm">
4242
* <h3>Enter your name:</h3>
4343
* <p>First: <input ng-control="first" required></p>
4444
* <p>Middle: <input ng-control="middle"></p>
@@ -73,7 +73,7 @@ const controlGroupProvider =
7373
selector: '[ng-control-group]',
7474
providers: [controlGroupProvider],
7575
inputs: ['name: ng-control-group'],
76-
exportAs: 'form'
76+
exportAs: 'ngForm'
7777
})
7878
export class NgControlGroup extends ControlContainer implements OnInit,
7979
OnDestroy {

modules/angular2/src/common/forms/directives/ng_control_name.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const controlNameBinding =
4949
* selector: "login-comp",
5050
* directives: [FORM_DIRECTIVES],
5151
* template: `
52-
* <form #f="form" (submit)='onLogIn(f.value)'>
53-
* Login <input type='text' ng-control='login' #l="form">
52+
* <form #f="ngForm" (submit)='onLogIn(f.value)'>
53+
* Login <input type='text' ng-control='login' #l="ngForm">
5454
* <div *ng-if="!l.valid">Login is invalid</div>
5555
*
5656
* Password <input type='password' ng-control='password'>
@@ -93,7 +93,7 @@ const controlNameBinding =
9393
bindings: [controlNameBinding],
9494
inputs: ['name: ngControl', 'model: ngModel'],
9595
outputs: ['update: ngModelChange'],
96-
exportAs: 'form'
96+
exportAs: 'ngForm'
9797
})
9898
export class NgControlName extends NgControl implements OnChanges,
9999
OnDestroy {

modules/angular2/src/common/forms/directives/ng_form.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const formDirectiveProvider =
4747
* <div>
4848
* <p>Submit the form to see the data object Angular builds</p>
4949
* <h2>NgForm demo</h2>
50-
* <form #f="form" (ng-submit)="onSubmit(f.value)">
50+
* <form #f="ngForm" (ng-submit)="onSubmit(f.value)">
5151
* <h3>Control group: credentials</h3>
5252
* <div ng-control-group="credentials">
5353
* <p>Login: <input type="text" ng-control="login"></p>
@@ -84,7 +84,7 @@ const formDirectiveProvider =
8484
'(submit)': 'onSubmit()',
8585
},
8686
outputs: ['ngSubmit'],
87-
exportAs: 'form'
87+
exportAs: 'ngForm'
8888
})
8989
export class NgForm extends ControlContainer implements Form {
9090
form: ControlGroup;

modules/angular2/src/common/forms/directives/ng_form_control.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const formControlBinding =
7979
bindings: [formControlBinding],
8080
inputs: ['form: ngFormControl', 'model: ngModel'],
8181
outputs: ['update: ngModelChange'],
82-
exportAs: 'form'
82+
exportAs: 'ngForm'
8383
})
8484
export class NgFormControl extends NgControl implements OnChanges {
8585
form: Control;

modules/angular2/src/common/forms/directives/ng_form_model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const formDirectiveProvider =
100100
inputs: ['form: ng-form-model'],
101101
host: {'(submit)': 'onSubmit()'},
102102
outputs: ['ngSubmit'],
103-
exportAs: 'form'
103+
exportAs: 'ngForm'
104104
})
105105
export class NgFormModel extends ControlContainer implements Form,
106106
OnChanges {

modules/angular2/src/common/forms/directives/ng_model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const formControlBinding =
5252
bindings: [formControlBinding],
5353
inputs: ['model: ngModel'],
5454
outputs: ['update: ngModelChange'],
55-
exportAs: 'form'
55+
exportAs: 'ngForm'
5656
})
5757
export class NgModel extends NgControl implements OnChanges {
5858
/** @internal */

modules/angular2/test/common/forms/integration_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ export function main() {
968968
// {{x.valid}} used to crash because valid() tried to read a property
969969
// from form.control before it was set. This test verifies this bug is
970970
// fixed.
971-
var t = `<form><div ng-control-group="x" #x="form">
971+
var t = `<form><div ng-control-group="x" #x="ngForm">
972972
<input type="text" ng-control="test"></div>{{x.valid}}</form>`;
973973
var fixture: ComponentFixture;
974974
tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then(
@@ -1072,4 +1072,4 @@ function sortedClassList(el) {
10721072
var l = DOM.classList(el);
10731073
ListWrapper.sort(l);
10741074
return l;
1075-
}
1075+
}

modules/playground/src/model_driven_forms/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ShowError {
7878
template: `
7979
<h1>Checkout Form (Model Driven)</h1>
8080
81-
<form (ng-submit)="onSubmit()" [ng-form-model]="form" #f="form">
81+
<form (ng-submit)="onSubmit()" [ng-form-model]="form" #f="ngForm">
8282
<p>
8383
<label for="firstName">First Name</label>
8484
<input type="text" id="firstName" ng-control="firstName">

modules/playground/src/template_driven_forms/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ShowError {
100100
template: `
101101
<h1>Checkout Form</h1>
102102
103-
<form (ng-submit)="onSubmit()" #f="form">
103+
<form (ng-submit)="onSubmit()" #f="ngForm">
104104
<p>
105105
<label for="firstName">First Name</label>
106106
<input type="text" id="firstName" ng-control="firstName" [(ng-model)]="model.firstName" required>

0 commit comments

Comments
 (0)
X Tutup