Skip to content

Commit 653fcee

Browse files
karajelbourn
authored andcommittedJun 30, 2016
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
}

‎src/components/radio/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/radio/radio.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
fakeAsync,
99
tick
1010
} from '@angular/core/testing';
11-
import {FORM_DIRECTIVES, NgControl} from '@angular/common';
11+
import {FORM_DIRECTIVES, NgControl, disableDeprecatedForms, provideForms} from '@angular/forms';
1212
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
1313
import {Component, DebugElement, provide} from '@angular/core';
1414
import {By} from '@angular/platform-browser';
@@ -23,6 +23,8 @@ describe('MdRadio', () => {
2323
let dispatcher: MdUniqueSelectionDispatcher;
2424

2525
beforeEachProviders(() => [
26+
disableDeprecatedForms(),
27+
provideForms(),
2628
provide(MdUniqueSelectionDispatcher, {useFactory: () => {
2729
dispatcher = new MdUniqueSelectionDispatcher();
2830
return dispatcher;
@@ -278,7 +280,7 @@ describe('MdRadio', () => {
278280
expect(groupInstance.selected.value).toBe(groupInstance.value);
279281
});
280282

281-
it('should have the correct ngControl state initially and after interaction', fakeAsync(() => {
283+
it('should have the correct control state initially and after interaction', fakeAsync(() => {
282284
// The control should start off valid, pristine, and untouched.
283285
expect(groupNgControl.valid).toBe(true);
284286
expect(groupNgControl.pristine).toBe(true);

‎src/components/radio/radio.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 {
2222
MdUniqueSelectionDispatcher
2323
} from '@angular2-material/core/coordination/unique-selection-dispatcher';

‎src/components/slide-toggle/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
}

‎src/components/slide-toggle/slide-toggle.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ import {
33
describe,
44
expect,
55
beforeEach,
6+
beforeEachProviders,
67
inject,
78
async
89
} from '@angular/core/testing';
910
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
1011
import {By} from '@angular/platform-browser';
1112
import {Component} from '@angular/core';
1213
import {MdSlideToggle, MdSlideToggleChange} from './slide-toggle';
13-
import {NgControl} from '@angular/common';
14+
import {NgControl, disableDeprecatedForms, provideForms} from '@angular/forms';
1415

1516
describe('MdSlideToggle', () => {
1617
let builder: TestComponentBuilder;
1718

19+
beforeEachProviders(() => [
20+
disableDeprecatedForms(),
21+
provideForms(),
22+
]);
23+
1824
beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
1925
builder = tcb;
2026
}));
@@ -244,7 +250,7 @@ describe('MdSlideToggle', () => {
244250
fixture.detectChanges();
245251
});
246252

247-
it('should have the correct ngControl state initially and after interaction', () => {
253+
it('should have the correct control state initially and after interaction', () => {
248254
// The control should start off valid, pristine, and untouched.
249255
expect(slideToggleControl.valid).toBe(true);
250256
expect(slideToggleControl.pristine).toBe(true);
@@ -269,7 +275,7 @@ describe('MdSlideToggle', () => {
269275
expect(slideToggleControl.touched).toBe(true);
270276
});
271277

272-
it('should not set the ngControl to touched when changing the state programmatically', () => {
278+
it('should not set the control to touched when changing the state programmatically', () => {
273279
// The control should start off with being untouched.
274280
expect(slideToggleControl.touched).toBe(false);
275281

@@ -288,7 +294,7 @@ describe('MdSlideToggle', () => {
288294
expect(slideToggleElement.classList).not.toContain('md-checked');
289295
});
290296

291-
it('should not set the ngControl to touched when changing the model', () => {
297+
it('should not set the control to touched when changing the model', () => {
292298
// The control should start off with being untouched.
293299
expect(slideToggleControl.touched).toBe(false);
294300

‎src/components/slide-toggle/slide-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import {
1313
ControlValueAccessor,
1414
NG_VALUE_ACCESSOR
15-
} from '@angular/common';
15+
} from '@angular/forms';
1616
import { BooleanFieldValue } from '@angular2-material/core/annotations/field-value';
1717
import { Observable } from 'rxjs/Observable';
1818

‎src/demo-app/checkbox/checkbox-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h1>md-checkbox: Basic Example</h1>
22
<form>
33
<md-checkbox [(ngModel)]="isChecked"
4-
ngControl="cb"
4+
name="cb"
55
(change)="isIndeterminate = false"
66
[indeterminate]="isIndeterminate"
77
[disabled]="isDisabled"

‎src/demo-app/checkbox/checkbox-demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from '@angular/core';
2-
import {NgFor, FORM_DIRECTIVES} from '@angular/common';
2+
import {NgFor} from '@angular/common';
3+
import {FORM_DIRECTIVES} from '@angular/forms';
34
import {MdCheckbox} from '@angular2-material/checkbox/checkbox';
45

56
export interface Task {

‎src/demo-app/grid-list/grid-list-demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from '@angular/core';
2-
import {NgFor, FORM_DIRECTIVES} from '@angular/common';
2+
import {NgFor} from '@angular/common';
3+
import {FORM_DIRECTIVES} from '@angular/forms';
34
import {MD_GRID_LIST_DIRECTIVES} from '@angular2-material/grid-list/grid-list';
45
import {MdButton} from '@angular2-material/button/button';
56
import {MD_CARD_DIRECTIVES} from '@angular2-material/card/card';

‎src/demo-app/input/input-demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from '@angular/core';
2-
import {FORM_DIRECTIVES, NgFor} from '@angular/common';
2+
import {NgFor} from '@angular/common';
3+
import {FORM_DIRECTIVES} from '@angular/forms';
34
import {MD_INPUT_DIRECTIVES} from '@angular2-material/input/input';
45
import {MdButton} from '@angular2-material/button/button';
56
import {MdCard} from '@angular2-material/card/card';

‎src/demo-app/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';
33
import {HTTP_PROVIDERS} from '@angular/http';
44
import {provide} from '@angular/core';
55
import {Renderer} from '@angular/core';
6+
import {disableDeprecatedForms, provideForms} from '@angular/forms';
67

78
import {OVERLAY_CONTAINER_TOKEN} from '@angular2-material/core/overlay/overlay';
89
import {MdLiveAnnouncer} from '@angular2-material/core/a11y/live-announcer';
@@ -15,10 +16,12 @@ import {DEMO_APP_ROUTE_PROVIDER} from './demo-app/routes';
1516

1617
bootstrap(DemoApp, [
1718
DEMO_APP_ROUTE_PROVIDER,
19+
disableDeprecatedForms(),
20+
provideForms(),
1821
MdLiveAnnouncer,
1922
provide(OVERLAY_CONTAINER_TOKEN, {useValue: createOverlayContainer()}),
2023
HTTP_PROVIDERS,
2124
MdIconRegistry,
2225
Renderer,
23-
provide(HAMMER_GESTURE_CONFIG, {useClass: MdGestureConfig})
26+
provide(HAMMER_GESTURE_CONFIG, {useClass: MdGestureConfig}),
2427
]);

‎src/demo-app/radio/radio-demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from '@angular/core';
2-
import {FORM_DIRECTIVES, NgFor} from '@angular/common';
2+
import {NgFor} from '@angular/common';
3+
import {FORM_DIRECTIVES} from '@angular/forms';
34
import {MdCheckbox} from '@angular2-material/checkbox/checkbox';
45
import {MD_RADIO_DIRECTIVES} from '@angular2-material/radio/radio';
56
import {

‎src/demo-app/slide-toggle/slide-toggle-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {FORM_DIRECTIVES} from '@angular/common';
2+
import {FORM_DIRECTIVES} from '@angular/forms';
33
import {MdSlideToggle} from '@angular2-material/slide-toggle/slide-toggle';
44

55
@Component({

‎src/demo-app/system-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const barrels: string[] = [
5555
'@angular/common',
5656
'@angular/compiler',
5757
'@angular/http',
58+
'@angular/forms',
5859
'@angular/router',
5960
'@angular/platform-browser',
6061
'@angular/platform-browser-dynamic',

‎src/demo-app/tabs/tab-group-demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component, ViewEncapsulation} from '@angular/core';
2-
import {FORM_DIRECTIVES, NgIf, NgFor, AsyncPipe} from '@angular/common';
2+
import {NgIf, NgFor, AsyncPipe} from '@angular/common';
3+
import {FORM_DIRECTIVES} from '@angular/forms';
34
import {MD_TABS_DIRECTIVES} from '@angular2-material/tabs/tabs';
45
import {MdToolbar} from '@angular2-material/toolbar/toolbar';
56
import {MdInput} from '@angular2-material/input/input';

0 commit comments

Comments
 (0)