Skip to content

Commit 5b516c2

Browse files
Merge pull request dschnelldavis#170 from jscharett/master
Fixed lazy loaded modules issue
2 parents ca138ed + e0ff027 commit 5b516c2

File tree

6 files changed

+64
-31
lines changed

6 files changed

+64
-31
lines changed
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

44
import { WidgetLibraryModule } from '../../widget-library/widget-library.module';
55

6-
import { WidgetLibraryService } from '../../widget-library/widget-library.service';
7-
import { FrameworkLibraryService } from '../framework-library.service';
6+
import { JsonSchemaFormService } from '../../json-schema-form.service';
87

98
import { Bootstrap3FrameworkComponent } from './bootstrap-3-framework.component';
109

1110
@NgModule({
1211
imports: [ CommonModule, WidgetLibraryModule ],
1312
declarations: [ Bootstrap3FrameworkComponent ],
1413
exports: [ Bootstrap3FrameworkComponent ],
15-
entryComponents: [ Bootstrap3FrameworkComponent ],
16-
providers: [ WidgetLibraryService, FrameworkLibraryService ]
14+
entryComponents: [ Bootstrap3FrameworkComponent ]
1715
})
18-
export class Bootstrap3FrameworkModule { }
16+
export class Bootstrap3FrameworkModule {
17+
static forRoot(): ModuleWithProviders {
18+
return {
19+
ngModule: Bootstrap3FrameworkModule,
20+
providers: [ JsonSchemaFormService ]
21+
}
22+
}
23+
}
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

44
import { WidgetLibraryModule } from '../../widget-library/widget-library.module';
55

6-
import { WidgetLibraryService } from '../../widget-library/widget-library.service';
7-
import { FrameworkLibraryService } from '../framework-library.service';
6+
import { JsonSchemaFormService } from '../../json-schema-form.service';
87

98
import { Bootstrap4FrameworkComponent } from './bootstrap-4-framework.component';
109

1110
@NgModule({
1211
imports: [ CommonModule, WidgetLibraryModule ],
1312
declarations: [ Bootstrap4FrameworkComponent ],
1413
exports: [ Bootstrap4FrameworkComponent ],
15-
entryComponents: [ Bootstrap4FrameworkComponent ],
16-
providers: [ WidgetLibraryService, FrameworkLibraryService ]
14+
entryComponents: [ Bootstrap4FrameworkComponent ]
1715
})
18-
export class Bootstrap4FrameworkModule { }
16+
export class Bootstrap4FrameworkModule {
17+
static forRoot(): ModuleWithProviders {
18+
return {
19+
ngModule: Bootstrap4FrameworkModule,
20+
providers: [ JsonSchemaFormService ]
21+
}
22+
}
23+
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33

4-
import { WidgetLibraryModule } from '../widget-library/widget-library.module';
54
import { WidgetLibraryService } from '../widget-library/widget-library.service';
5+
import { WidgetLibraryModule } from '../widget-library/widget-library.module';
66

77
import { FrameworkLibraryService } from './framework-library.service';
88
import { NoFrameworkComponent } from './no-framework.component';
@@ -15,7 +15,13 @@ import { NoFrameworkComponent } from './no-framework.component';
1515
exports: [
1616
NoFrameworkComponent,
1717
],
18-
entryComponents: [ NoFrameworkComponent ],
19-
providers: [ WidgetLibraryService, FrameworkLibraryService ]
18+
entryComponents: [ NoFrameworkComponent ]
2019
})
21-
export class FrameworkLibraryModule { }
20+
export class FrameworkLibraryModule {
21+
static forRoot(): ModuleWithProviders {
22+
return {
23+
ngModule: FrameworkLibraryModule,
24+
providers: [ WidgetLibraryService, FrameworkLibraryService ]
25+
}
26+
}
27+
}

src/lib/src/framework-library/material-design-framework/material-design-framework.module.ts

Lines changed: 10 additions & 4 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 { CommonModule } from '@angular/common';
33
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
44
import { FlexLayoutModule } from '@angular/flex-layout';
@@ -36,7 +36,13 @@ import { MATERIAL_FRAMEWORK_COMPONENTS } from './index';
3636
],
3737
declarations: [ ...MATERIAL_FRAMEWORK_COMPONENTS ],
3838
exports: [ ...MATERIAL_FRAMEWORK_COMPONENTS ],
39-
entryComponents: [ ...MATERIAL_FRAMEWORK_COMPONENTS ],
40-
providers: [ JsonSchemaFormService ]
39+
entryComponents: [ ...MATERIAL_FRAMEWORK_COMPONENTS ]
4140
})
42-
export class MaterialDesignFrameworkModule { }
41+
export class MaterialDesignFrameworkModule {
42+
static forRoot(): ModuleWithProviders {
43+
return {
44+
ngModule: MaterialDesignFrameworkModule,
45+
providers: [ JsonSchemaFormService ]
46+
}
47+
}
48+
}
Lines changed: 11 additions & 6 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 { CommonModule } from '@angular/common';
33
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
44

@@ -8,7 +8,6 @@ import { WidgetLibraryModule } from './widget-library/widget-library.module';
88
import { JsonSchemaFormComponent } from './json-schema-form.component';
99

1010
import { JsonSchemaFormService } from './json-schema-form.service';
11-
import { FrameworkLibraryService } from './framework-library/framework-library.service';
1211

1312
@NgModule({
1413
imports: [
@@ -18,9 +17,15 @@ import { FrameworkLibraryService } from './framework-library/framework-library.s
1817
declarations: [ JsonSchemaFormComponent ],
1918
exports: [
2019
JsonSchemaFormComponent, FrameworkLibraryModule, WidgetLibraryModule
21-
],
22-
providers: [
23-
JsonSchemaFormService, FrameworkLibraryService
2420
]
2521
})
26-
export class JsonSchemaFormModule { }
22+
export class JsonSchemaFormModule {
23+
static forRoot(): ModuleWithProviders {
24+
return {
25+
ngModule: JsonSchemaFormModule,
26+
providers: [ ]
27+
.concat([JsonSchemaFormService])
28+
.concat(FrameworkLibraryModule.forRoot().providers)
29+
}
30+
}
31+
}
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
44

55
import { OrderableDirective } from '../shared/orderable.directive';
66

7-
import { WidgetLibraryService } from './widget-library.service';
87
import { JsonSchemaFormService } from '../json-schema-form.service';
98

109
import { BASIC_WIDGETS } from './index';
@@ -14,6 +13,13 @@ import { BASIC_WIDGETS } from './index';
1413
declarations: [ ...BASIC_WIDGETS, OrderableDirective ],
1514
exports: [ ...BASIC_WIDGETS, OrderableDirective ],
1615
entryComponents: [ ...BASIC_WIDGETS ],
17-
providers: [ JsonSchemaFormService, WidgetLibraryService ]
16+
providers: [ JsonSchemaFormService ]
1817
})
19-
export class WidgetLibraryModule { }
18+
export class WidgetLibraryModule {
19+
static forRoot(): ModuleWithProviders {
20+
return {
21+
ngModule: WidgetLibraryModule,
22+
providers: [ JsonSchemaFormService ]
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)