@@ -11,12 +11,10 @@ import {
11
11
NgModule ,
12
12
Optional ,
13
13
PLATFORM_ID ,
14
- Provider ,
15
14
} from '@angular/core' ;
16
15
import { isPlatformServer } from '@angular/common' ;
17
16
import {
18
17
SERVER_TOKEN ,
19
- DEFAULT_CONFIG ,
20
18
LayoutConfigOptions ,
21
19
LAYOUT_CONFIG ,
22
20
BreakPoint ,
@@ -50,30 +48,26 @@ export class FlexLayoutModule {
50
48
*/
51
49
static withConfig ( configOptions : LayoutConfigOptions ,
52
50
breakpoints ?: BreakPoint | BreakPoint [ ] ) : ModuleWithProviders {
53
- const config = Object . assign ( { } , DEFAULT_CONFIG ) ;
54
- const moduleProviders : Provider [ ] = [ ] ;
55
-
56
- for ( const key in configOptions ) {
57
- // If the setting is different and not undefined or null, change it
58
- if ( configOptions [ key ] !== config [ key ] &&
59
- ( configOptions [ key ] === false || configOptions [ key ] === true ) ) {
60
- config [ key ] = configOptions [ key ] ;
61
- }
62
- }
63
-
64
- if ( configOptions . serverLoaded ) {
65
- moduleProviders . push ( { provide : SERVER_TOKEN , useValue : true } ) ;
66
- }
67
-
68
- if ( Array . isArray ( breakpoints ) ) {
69
- moduleProviders . push ( { provide : BREAKPOINT , useValue : breakpoints , multi : true } ) ;
70
- }
71
-
72
- moduleProviders . push ( { provide : LAYOUT_CONFIG , useValue : config } ) ;
73
-
74
51
return {
75
52
ngModule : FlexLayoutModule ,
76
- providers : moduleProviders
53
+ providers : Array . isArray ( breakpoints ) ?
54
+ configOptions . serverLoaded ?
55
+ [
56
+ { provide : LAYOUT_CONFIG , useValue : configOptions } ,
57
+ { provide : BREAKPOINT , useValue : breakpoints , multi : true } ,
58
+ { provide : SERVER_TOKEN , useValue : true } ,
59
+ ] : [
60
+ { provide : LAYOUT_CONFIG , useValue : configOptions } ,
61
+ { provide : BREAKPOINT , useValue : breakpoints , multi : true } ,
62
+ ]
63
+ :
64
+ configOptions . serverLoaded ?
65
+ [
66
+ { provide : LAYOUT_CONFIG , useValue : configOptions } ,
67
+ ] :
68
+ [
69
+ { provide : LAYOUT_CONFIG , useValue : configOptions } ,
70
+ ]
77
71
} ;
78
72
}
79
73
0 commit comments