Skip to content

Commit 21dc44a

Browse files
authored
fix(all): add forRoot() to all modules (#1166)
1 parent 3ef7ece commit 21dc44a

29 files changed

+164
-45
lines changed

src/lib/all/all.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,29 @@ const MATERIAL_MODULES = [
5555

5656
@NgModule({
5757
imports: [
58-
MdButtonModule,
59-
MdCardModule,
60-
MdCheckboxModule,
61-
MdGridListModule,
62-
MdInputModule,
63-
MdListModule,
64-
MdProgressBarModule,
65-
MdProgressCircleModule,
66-
MdRippleModule,
67-
MdSidenavModule,
68-
MdSliderModule,
69-
MdSlideToggleModule,
70-
MdTabsModule,
71-
MdToolbarModule,
72-
PortalModule,
73-
RtlModule,
58+
MdButtonModule.forRoot(),
59+
MdCardModule.forRoot(),
60+
MdCheckboxModule.forRoot(),
61+
MdGridListModule.forRoot(),
62+
MdInputModule.forRoot(),
63+
MdListModule.forRoot(),
64+
MdProgressBarModule.forRoot(),
65+
MdProgressCircleModule.forRoot(),
66+
MdRippleModule.forRoot(),
67+
MdSidenavModule.forRoot(),
68+
MdTabsModule.forRoot(),
69+
MdToolbarModule.forRoot(),
70+
PortalModule.forRoot(),
71+
RtlModule.forRoot(),
7472

7573
// These modules include providers.
7674
MdButtonToggleModule.forRoot(),
7775
MdDialogModule.forRoot(),
7876
MdIconModule.forRoot(),
7977
MdMenuModule.forRoot(),
8078
MdRadioModule.forRoot(),
79+
MdSliderModule.forRoot(),
80+
MdSlideToggleModule.forRoot(),
8181
MdTooltipModule.forRoot(),
8282
OverlayModule.forRoot(),
8383
],

src/lib/button/button.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('MdButton', () => {
1111

1212
beforeEach(async(() => {
1313
TestBed.configureTestingModule({
14-
imports: [MdButtonModule],
14+
imports: [MdButtonModule.forRoot()],
1515
declarations: [TestApp],
1616
});
1717

src/lib/button/button.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ElementRef,
88
Renderer,
99
NgModule,
10+
ModuleWithProviders,
1011
} from '@angular/core';
1112
import {CommonModule} from '@angular/common';
1213
import {BooleanFieldValue} from '@angular2-material/core';
@@ -161,4 +162,11 @@ export class MdAnchor extends MdButton {
161162
exports: [MdButton, MdAnchor],
162163
declarations: [MdButton, MdAnchor],
163164
})
164-
export class MdButtonModule { }
165+
export class MdButtonModule {
166+
static forRoot(): ModuleWithProviders {
167+
return {
168+
ngModule: MdButtonModule,
169+
providers: []
170+
};
171+
}
172+
}

src/lib/card/card.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
Component,
45
ViewEncapsulation,
56
ChangeDetectionStrategy,
@@ -124,4 +125,11 @@ export class MdCardTitleGroup {}
124125
MdCardActions
125126
],
126127
})
127-
export class MdCardModule { }
128+
export class MdCardModule {
129+
static forRoot(): ModuleWithProviders {
130+
return {
131+
ngModule: MdCardModule,
132+
providers: []
133+
};
134+
}
135+
}

src/lib/checkbox/checkbox.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('MdCheckbox', () => {
2121

2222
beforeEach(async(() => {
2323
TestBed.configureTestingModule({
24-
imports: [MdCheckboxModule, FormsModule],
24+
imports: [MdCheckboxModule.forRoot(), FormsModule],
2525
declarations: [
2626
SingleCheckbox,
2727
CheckboxWithFormDirectives,

src/lib/checkbox/checkbox.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ViewEncapsulation,
1010
forwardRef,
1111
NgModule,
12+
ModuleWithProviders,
1213
} from '@angular/core';
1314
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
1415

@@ -309,4 +310,11 @@ export class MdCheckbox implements ControlValueAccessor {
309310
exports: [MdCheckbox],
310311
declarations: [MdCheckbox],
311312
})
312-
export class MdCheckboxModule { }
313+
export class MdCheckboxModule {
314+
static forRoot(): ModuleWithProviders {
315+
return {
316+
ngModule: MdCheckboxModule,
317+
providers: []
318+
};
319+
}
320+
}

src/lib/core/portal/portal-directives.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
ComponentRef,
45
Directive,
56
TemplateRef,
@@ -107,4 +108,11 @@ export class PortalHostDirective extends BasePortalHost {
107108
exports: [TemplatePortalDirective, PortalHostDirective],
108109
declarations: [TemplatePortalDirective, PortalHostDirective],
109110
})
110-
export class PortalModule { }
111+
export class PortalModule {
112+
static forRoot(): ModuleWithProviders {
113+
return {
114+
ngModule: PortalModule,
115+
providers: []
116+
};
117+
}
118+
}

src/lib/core/portal/portal.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Portals', () => {
2525

2626
beforeEach(async(() => {
2727
TestBed.configureTestingModule({
28-
imports: [PortalModule, PortalTestModule],
28+
imports: [PortalModule.forRoot(), PortalTestModule],
2929
});
3030

3131
TestBed.compileComponents();

src/lib/core/ripple/ripple.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('MdRipple', () => {
6363

6464
beforeEach(() => {
6565
TestBed.configureTestingModule({
66-
imports: [MdRippleModule],
66+
imports: [MdRippleModule.forRoot()],
6767
declarations: [BasicRippleContainer, RippleContainerWithInputBindings],
6868
});
6969
});

src/lib/core/ripple/ripple.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
Directive,
45
ElementRef,
56
HostBinding,
@@ -173,4 +174,11 @@ export class MdRipple implements OnInit, OnDestroy, OnChanges {
173174
exports: [MdRipple],
174175
declarations: [MdRipple],
175176
})
176-
export class MdRippleModule { }
177+
export class MdRippleModule {
178+
static forRoot(): ModuleWithProviders {
179+
return {
180+
ngModule: MdRippleModule,
181+
providers: []
182+
};
183+
}
184+
}

src/lib/core/rtl/dir.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {NgModule, Directive, HostBinding, Output, Input, EventEmitter} from '@angular/core';
1+
import {
2+
NgModule,
3+
ModuleWithProviders,
4+
Directive,
5+
HostBinding,
6+
Output,
7+
Input,
8+
EventEmitter
9+
} from '@angular/core';
210

311
export type LayoutDirection = 'ltr' | 'rtl';
412

@@ -39,4 +47,11 @@ export class Dir {
3947
exports: [Dir],
4048
declarations: [Dir]
4149
})
42-
export class RtlModule { }
50+
export class RtlModule {
51+
static forRoot(): ModuleWithProviders {
52+
return {
53+
ngModule: RtlModule,
54+
providers: []
55+
};
56+
}
57+
}

src/lib/grid-list/grid-list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {MdGridTile, MdGridTileText} from './grid-tile';
88
describe('MdGridList', () => {
99
beforeEach(async(() => {
1010
TestBed.configureTestingModule({
11-
imports: [MdGridListModule],
11+
imports: [MdGridListModule.forRoot()],
1212
declarations: [
1313
GridListWithoutCols,
1414
GridListWithInvalidRowHeightRatio,

src/lib/grid-list/grid-list.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
Component,
45
ViewEncapsulation,
56
AfterContentChecked,
@@ -156,4 +157,11 @@ export class MdGridList implements OnInit, AfterContentChecked {
156157
exports: [MdGridList, MdGridTile, MdGridTileText, MdLineModule],
157158
declarations: [MdGridList, MdGridTile, MdGridTileText],
158159
})
159-
export class MdGridListModule { }
160+
export class MdGridListModule {
161+
static forRoot(): ModuleWithProviders {
162+
return {
163+
ngModule: MdGridListModule,
164+
providers: []
165+
};
166+
}
167+
}

src/lib/input/input.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {MdInput, MdInputModule} from './input';
1111
describe('MdInput', function () {
1212
beforeEach(async(() => {
1313
TestBed.configureTestingModule({
14-
imports: [MdInputModule, FormsModule],
14+
imports: [MdInputModule.forRoot(), FormsModule],
1515
declarations: [
1616
MdInputNumberTypeConservedTestComponent,
1717
MdInputPlaceholderRequiredTestComponent,

src/lib/input/input.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
EventEmitter,
1616
Output,
1717
NgModule,
18+
ModuleWithProviders,
1819
} from '@angular/core';
1920
import {
2021
NG_VALUE_ACCESSOR,
@@ -312,4 +313,11 @@ export class MdInput implements ControlValueAccessor, AfterContentInit, OnChange
312313
imports: [CommonModule, FormsModule],
313314
exports: [MdPlaceholder, MdInput, MdHint],
314315
})
315-
export class MdInputModule { }
316+
export class MdInputModule {
317+
static forRoot(): ModuleWithProviders {
318+
return {
319+
ngModule: MdInputModule,
320+
providers: []
321+
};
322+
}
323+
}

src/lib/list/list.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('MdList', () => {
88

99
beforeEach(async(() => {
1010
TestBed.configureTestingModule({
11-
imports: [MdListModule],
11+
imports: [MdListModule.forRoot()],
1212
declarations: [
1313
ListWithOneAnchorItem,
1414
ListWithOneItem,

src/lib/list/list.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Renderer,
1010
AfterContentInit,
1111
NgModule,
12+
ModuleWithProviders,
1213
} from '@angular/core';
1314
import {MdLine, MdLineSetter, MdLineModule} from '@angular2-material/core';
1415

@@ -76,4 +77,11 @@ export class MdListItem implements AfterContentInit {
7677
exports: [MdList, MdListItem, MdListDivider, MdListAvatar, MdLineModule],
7778
declarations: [MdList, MdListItem, MdListDivider, MdListAvatar],
7879
})
79-
export class MdListModule { }
80+
export class MdListModule {
81+
static forRoot(): ModuleWithProviders {
82+
return {
83+
ngModule: MdListModule,
84+
providers: []
85+
};
86+
}
87+
}

src/lib/progress-bar/progress-bar.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('MdProgressBar', () => {
88

99
beforeEach(async(() => {
1010
TestBed.configureTestingModule({
11-
imports: [MdProgressBarModule],
11+
imports: [MdProgressBarModule.forRoot()],
1212
declarations: [
1313
BasicProgressBar,
1414
BufferProgressBar,

src/lib/progress-bar/progress-bar.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
Component,
45
ChangeDetectionStrategy,
56
HostBinding,
@@ -92,4 +93,11 @@ function clamp(v: number, min = 0, max = 100) {
9293
exports: [MdProgressBar],
9394
declarations: [MdProgressBar],
9495
})
95-
export class MdProgressBarModule { }
96+
export class MdProgressBarModule {
97+
static forRoot(): ModuleWithProviders {
98+
return {
99+
ngModule: MdProgressBarModule,
100+
providers: []
101+
};
102+
}
103+
}

src/lib/progress-circle/progress-circle.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('MdProgressCircular', () => {
88

99
beforeEach(async(() => {
1010
TestBed.configureTestingModule({
11-
imports: [MdProgressCircleModule],
11+
imports: [MdProgressCircleModule.forRoot()],
1212
declarations: [
1313
BasicProgressSpinner,
1414
IndeterminateProgressSpinner,

src/lib/progress-circle/progress-circle.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
Component,
45
HostBinding,
56
ChangeDetectorRef,
@@ -318,4 +319,11 @@ function getSvgArc(currentValue: number, rotation: number) {
318319
exports: [MdProgressCircle, MdSpinner],
319320
declarations: [MdProgressCircle, MdSpinner],
320321
})
321-
export class MdProgressCircleModule { }
322+
export class MdProgressCircleModule {
323+
static forRoot(): ModuleWithProviders {
324+
return {
325+
ngModule: MdProgressCircleModule,
326+
providers: []
327+
};
328+
}
329+
}

src/lib/sidenav/sidenav.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('MdSidenav', () => {
1818

1919
beforeEach(async(() => {
2020
TestBed.configureTestingModule({
21-
imports: [MdSidenavModule],
21+
imports: [MdSidenavModule.forRoot()],
2222
declarations: [
2323
BasicTestApp,
2424
SidenavLayoutTwoSidenavTestApp,

src/lib/sidenav/sidenav.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
AfterContentInit,
45
Component,
56
ContentChildren,
@@ -389,4 +390,11 @@ export class MdSidenavLayout implements AfterContentInit {
389390
exports: [MdSidenavLayout, MdSidenav],
390391
declarations: [MdSidenavLayout, MdSidenav],
391392
})
392-
export class MdSidenavModule { }
393+
export class MdSidenavModule {
394+
static forRoot(): ModuleWithProviders {
395+
return {
396+
ngModule: MdSidenavModule,
397+
providers: []
398+
};
399+
}
400+
}

src/lib/slide-toggle/slide-toggle.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('MdSlideToggle', () => {
88

99
beforeEach(async(() => {
1010
TestBed.configureTestingModule({
11-
imports: [MdSlideToggleModule, FormsModule],
11+
imports: [MdSlideToggleModule.forRoot(), FormsModule],
1212
declarations: [SlideToggleTestApp],
1313
});
1414

0 commit comments

Comments
 (0)