Skip to content

Commit 9ff6196

Browse files
authored
feat(modules): add forRoot to material modules (#1122)
1 parent 2c0dfcb commit 9ff6196

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+212
-181
lines changed

src/demo-app/demo-app-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import {TabsDemo} from './tabs/tab-group-demo';
3939
BrowserModule,
4040
FormsModule,
4141
HttpModule,
42-
MaterialModule,
43-
RouterModule.forRoot(DEMO_APP_ROUTES)
42+
RouterModule.forRoot(DEMO_APP_ROUTES),
43+
MaterialModule.forRoot(),
4444
],
4545
declarations: [
4646
BaselineDemo,

src/demo-app/dialog/dialog-demo.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import {Component, ViewContainerRef} from '@angular/core';
22
import {MdDialog, MdDialogConfig, MdDialogRef} from '@angular2-material/dialog/dialog';
3-
import {OVERLAY_PROVIDERS} from '@angular2-material/core/overlay/overlay';
43

54
@Component({
65
moduleId: module.id,
76
selector: 'dialog-demo',
87
templateUrl: 'dialog-demo.html',
98
styleUrls: ['dialog-demo.css'],
10-
providers: [MdDialog, OVERLAY_PROVIDERS]
119
})
1210
export class DialogDemo {
1311
dialogRef: MdDialogRef<JazzDialog>;

src/demo-app/overlay/overlay-demo.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
Overlay,
1111
OverlayState,
1212
OverlayOrigin,
13-
OVERLAY_PROVIDERS,
1413
ComponentPortal,
1514
Portal,
1615
TemplatePortalDirective,
@@ -22,7 +21,6 @@ import {
2221
selector: 'overlay-demo',
2322
templateUrl: 'overlay-demo.html',
2423
styleUrls: ['overlay-demo.css'],
25-
providers: [OVERLAY_PROVIDERS],
2624
encapsulation: ViewEncapsulation.None,
2725
})
2826
export class OverlayDemo {

src/e2e-app/e2e-app-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {E2E_APP_ROUTES} from './e2e-app/routes';
1313
@NgModule({
1414
imports: [
1515
BrowserModule,
16-
MaterialModule,
1716
RouterModule.forRoot(E2E_APP_ROUTES),
17+
MaterialModule.forRoot(),
1818
],
1919
declarations: [
2020
E2EApp,

src/lib/all/all.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {NgModule} from '@angular/core';
1+
import {NgModule, ModuleWithProviders} from '@angular/core';
22
import {MdButtonToggleModule} from '@angular2-material/button-toggle/button-toggle';
33
import {MdButtonModule} from '@angular2-material/button/button';
44
import {MdCheckboxModule} from '@angular2-material/checkbox/checkbox';
@@ -52,8 +52,45 @@ const MATERIAL_MODULES = [
5252
];
5353

5454
@NgModule({
55-
imports: MATERIAL_MODULES,
55+
imports: [
56+
MdButtonModule,
57+
MdCardModule,
58+
MdCheckboxModule,
59+
MdGridListModule,
60+
MdInputModule,
61+
MdListModule,
62+
MdProgressBarModule,
63+
MdProgressCircleModule,
64+
MdRippleModule,
65+
MdSidenavModule,
66+
MdSliderModule,
67+
MdSlideToggleModule,
68+
MdTabsModule,
69+
MdToolbarModule,
70+
PortalModule,
71+
RtlModule,
72+
73+
// These modules include providers.
74+
MdButtonToggleModule.forRoot(),
75+
MdDialogModule.forRoot(),
76+
MdIconModule.forRoot(),
77+
MdMenuModule.forRoot(),
78+
MdRadioModule.forRoot(),
79+
MdTooltipModule.forRoot(),
80+
OverlayModule.forRoot(),
81+
],
5682
exports: MATERIAL_MODULES,
5783
providers: [MdLiveAnnouncer]
5884
})
59-
export class MaterialModule { }
85+
export class MaterialRootModule { }
86+
87+
88+
@NgModule({
89+
imports: MATERIAL_MODULES,
90+
exports: MATERIAL_MODULES,
91+
})
92+
export class MaterialModule {
93+
static forRoot(): ModuleWithProviders {
94+
return {ngModule: MaterialRootModule};
95+
}
96+
}

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

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

2121
beforeEach(async(() => {
2222
TestBed.configureTestingModule({
23-
imports: [MdButtonToggleModule, FormsModule],
23+
imports: [MdButtonToggleModule.forRoot(), FormsModule],
2424
declarations: [
2525
ButtonTogglesInsideButtonToggleGroup,
2626
ButtonToggleGroupWithNgModel,

src/lib/button-toggle/button-toggle.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NgModule,
3+
ModuleWithProviders,
34
Component,
45
ContentChildren,
56
Directive,
@@ -385,18 +386,17 @@ export class MdButtonToggle implements OnInit {
385386
}
386387
}
387388

388-
/** @deprecated */
389-
export const MD_BUTTON_TOGGLE_DIRECTIVES = [
390-
MdButtonToggleGroup,
391-
MdButtonToggleGroupMultiple,
392-
MdButtonToggle
393-
];
394-
395389

396390
@NgModule({
397391
imports: [FormsModule],
398-
exports: MD_BUTTON_TOGGLE_DIRECTIVES,
399-
declarations: MD_BUTTON_TOGGLE_DIRECTIVES,
400-
providers: [MdUniqueSelectionDispatcher],
392+
exports: [MdButtonToggleGroup, MdButtonToggleGroupMultiple, MdButtonToggle],
393+
declarations: [MdButtonToggleGroup, MdButtonToggleGroupMultiple, MdButtonToggle],
401394
})
402-
export class MdButtonToggleModule { }
395+
export class MdButtonToggleModule {
396+
static forRoot(): ModuleWithProviders {
397+
return {
398+
ngModule: MdButtonToggleModule,
399+
providers: [MdUniqueSelectionDispatcher]
400+
};
401+
}
402+
}

src/lib/button/button.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,9 @@ export class MdAnchor extends MdButton {
156156
}
157157

158158

159-
/** @deprecated */
160-
export const MD_BUTTON_DIRECTIVES: any[] = [MdButton, MdAnchor];
161-
162-
163159
@NgModule({
164160
imports: [CommonModule, MdRippleModule],
165-
exports: MD_BUTTON_DIRECTIVES,
166-
declarations: MD_BUTTON_DIRECTIVES,
161+
exports: [MdButton, MdAnchor],
162+
declarations: [MdButton, MdAnchor],
167163
})
168164
export class MdButtonModule { }

src/lib/card/card.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ TODO(kara): update link to demo site when it exists
113113
})
114114
export class MdCardTitleGroup {}
115115

116-
/** @deprecated */
117-
export const MD_CARD_DIRECTIVES: any[] = [
118-
MdCard, MdCardContent, MdCardHeader, MdCardTitleGroup, MdCardTitle, MdCardSubtitle,
119-
MdCardActions
120-
];
121-
122116

123117
@NgModule({
124-
exports: MD_CARD_DIRECTIVES,
125-
declarations: MD_CARD_DIRECTIVES,
118+
exports: [
119+
MdCard, MdCardHeader, MdCardTitleGroup, MdCardContent, MdCardTitle, MdCardSubtitle,
120+
MdCardActions
121+
],
122+
declarations: [
123+
MdCard, MdCardHeader, MdCardTitleGroup, MdCardContent, MdCardTitle, MdCardSubtitle,
124+
MdCardActions
125+
],
126126
})
127127
export class MdCardModule { }

src/lib/checkbox/checkbox.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,9 @@ export class MdCheckbox implements ControlValueAccessor {
304304
}
305305
}
306306

307-
/** @deprecated */
308-
export const MD_CHECKBOX_DIRECTIVES = [MdCheckbox];
309-
310307

311308
@NgModule({
312-
exports: MD_CHECKBOX_DIRECTIVES,
313-
declarations: MD_CHECKBOX_DIRECTIVES,
309+
exports: [MdCheckbox],
310+
declarations: [MdCheckbox],
314311
})
315312
export class MdCheckboxModule { }

0 commit comments

Comments
 (0)