Skip to content

Commit 653fcee

Browse files
karajelbourn
authored andcommitted
fix(forms): update components to new forms module (#745)
1 parent 02cee7b commit 653fcee

27 files changed

+79
-33
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@angular/platform-browser": "2.0.0-rc.3",
3636
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
3737
"@angular/router": "v3.0.0-alpha.8",
38+
"@angular/forms": "^0.1.0",
3839
"core-js": "^2.4.0",
3940
"hammerjs": "^2.0.8",
4041
"rxjs": "5.0.0-beta.6",

src/components/button-toggle/button-toggle.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {
88
fakeAsync,
99
tick,
1010
} from '@angular/core/testing';
11-
// TODO(iveysaur): Update to @angular/forms when we have rc.2
12-
import {NgControl} from '@angular/common';
11+
import {NgControl, disableDeprecatedForms, provideForms} from '@angular/forms';
1312
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
1413
import {Component, DebugElement, provide} from '@angular/core';
1514
import {By} from '@angular/platform-browser';
@@ -30,6 +29,8 @@ describe('MdButtonToggle', () => {
3029
let dispatcher: MdUniqueSelectionDispatcher;
3130

3231
beforeEachProviders(() => [
32+
disableDeprecatedForms(),
33+
provideForms(),
3334
provide(MdUniqueSelectionDispatcher, {useFactory: () => {
3435
dispatcher = new MdUniqueSelectionDispatcher();
3536
return dispatcher;

src/components/button-toggle/button-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import {
1818
NG_VALUE_ACCESSOR,
1919
ControlValueAccessor,
20-
} from '@angular/common';
20+
} from '@angular/forms';
2121
import {Observable} from 'rxjs/Observable';
2222
import {
2323
MdUniqueSelectionDispatcher

src/components/checkbox/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A demo of the checkbox can be found at https://plnkr.co/edit/P7qce8lN9n2flS6kBhD
2727
### Usage within Forms
2828

2929
In addition to supporting native checkbox functionality, `md-checkbox` also supports `[(ngModel)]`
30-
and `ngControl` for use within forms.
30+
for use within forms.
3131

3232
```html
3333
<form (submit)="saveUser()">

src/components/checkbox/checkbox.spec.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import {
22
it,
33
beforeEach,
4+
beforeEachProviders,
45
inject,
56
async,
67
fakeAsync,
78
flushMicrotasks,
89
tick
910
} from '@angular/core/testing';
10-
import {FORM_DIRECTIVES, NgModel, NgControl} from '@angular/common';
11+
import {
12+
FORM_DIRECTIVES,
13+
NgModel,
14+
NgControl,
15+
disableDeprecatedForms,
16+
provideForms
17+
} from '@angular/forms';
1118
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
1219
import {Component, DebugElement} from '@angular/core';
1320
import {By} from '@angular/platform-browser';
@@ -22,6 +29,11 @@ describe('MdCheckbox', () => {
2229
let builder: TestComponentBuilder;
2330
let fixture: ComponentFixture<any>;
2431

32+
beforeEachProviders(() => [
33+
disableDeprecatedForms(),
34+
provideForms(),
35+
]);
36+
2537
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
2638
builder = tcb;
2739
}));
@@ -432,7 +444,7 @@ describe('MdCheckbox', () => {
432444
});
433445
});
434446

435-
describe('with ngModel and ngControl', () => {
447+
describe('with ngModel', () => {
436448
beforeEach(async(() => {
437449
builder.createAsync(CheckboxWithFormDirectives).then(f => {
438450
f.detectChanges();
@@ -501,12 +513,12 @@ class SingleCheckbox {
501513
onCheckboxClick(event: Event) {}
502514
}
503515

504-
/** Simple component for testing an MdCheckbox with ngModel and ngControl. */
516+
/** Simple component for testing an MdCheckbox with ngModel. */
505517
@Component({
506518
directives: [MdCheckbox, FORM_DIRECTIVES, NgModel],
507519
template: `
508520
<form>
509-
<md-checkbox ngControl="cb" [(ngModel)]="isGood">Be good</md-checkbox>
521+
<md-checkbox name="cb" [(ngModel)]="isGood">Be good</md-checkbox>
510522
</form>
511523
`,
512524
})

src/components/checkbox/checkbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
forwardRef,
1212
AfterContentInit
1313
} from '@angular/core';
14-
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/common';
14+
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
1515

1616
/**
1717
* Monotonically increasing integer used to auto-generate unique ids for checkbox components.
@@ -20,7 +20,7 @@ let nextId = 0;
2020

2121
/**
2222
* Provider Expression that allows md-checkbox to register as a ControlValueAccessor. This allows it
23-
* to support [(ngModel)] and ngControl.
23+
* to support [(ngModel)].
2424
*/
2525
export const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR = new Provider(
2626
NG_VALUE_ACCESSOR, {

src/components/checkbox/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.5-2"
24+
"@angular2-material/core": "2.0.0-alpha.5-2",
25+
"@angular/forms": "^0.1.0"
2526
}
2627
}

src/components/input/input.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import {
33
it,
44
expect,
55
beforeEach,
6+
beforeEachProviders,
67
fakeAsync,
78
inject,
89
tick,
910
} from '@angular/core/testing';
1011
import {TestComponentBuilder} from '@angular/compiler/testing';
1112
import {Component} from '@angular/core';
13+
import {disableDeprecatedForms, provideForms} from '@angular/forms';
1214
import {By} from '@angular/platform-browser';
1315
import {
1416
MdInput,
@@ -19,6 +21,11 @@ import {
1921
describe('MdInput', function () {
2022
var builder: TestComponentBuilder;
2123

24+
beforeEachProviders(() => [
25+
disableDeprecatedForms(),
26+
provideForms(),
27+
]);
28+
2229
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
2330
builder = tcb;
2431
}));

src/components/input/input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
NG_VALUE_ACCESSOR,
2121
ControlValueAccessor,
2222
NgModel,
23-
NgIf,
24-
} from '@angular/common';
23+
} from '@angular/forms';
24+
import {NgIf} from '@angular/common';
2525
import {BooleanFieldValue} from '@angular2-material/core/annotations/field-value';
2626
import {MdError} from '@angular2-material/core/errors/error';
2727
import {Observable} from 'rxjs/Observable';

src/components/input/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.5-2"
26+
"@angular2-material/core": "2.0.0-alpha.5-2",
27+
"@angular/forms": "^0.1.0"
2728
}
2829
}

0 commit comments

Comments
 (0)