File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
Component ,
12
12
Directive ,
13
13
Inject ,
14
+ InjectionToken ,
14
15
Injector ,
15
16
TemplateRef ,
16
17
ViewChild ,
@@ -125,6 +126,15 @@ describe('Dialog', () => {
125
126
) ;
126
127
} ) ;
127
128
129
+ it ( 'should use custom injector' , ( ) => {
130
+ const token = new InjectionToken < string > ( 'message' ) ;
131
+ const injector = Injector . create ( { providers : [ { provide : token , useValue : 'hello' } ] } ) ;
132
+ const dialogRef = dialog . open ( PizzaMsg , { injector} ) ;
133
+ viewContainerFixture . detectChanges ( ) ;
134
+
135
+ expect ( dialogRef . componentInstance ?. dialogInjector . get ( token ) ) . toBe ( 'hello' ) ;
136
+ } ) ;
137
+
128
138
it ( 'should open a dialog with a component and no ViewContainerRef' , ( ) => {
129
139
let dialogRef = dialog . open ( PizzaMsg ) ;
130
140
Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ export class Dialog implements OnDestroy {
333
333
} ) ;
334
334
}
335
335
336
- return Injector . create ( { parent : userInjector || this . _injector , providers} ) ;
336
+ return Injector . create ( { parent : config . injector || userInjector || this . _injector , providers} ) ;
337
337
}
338
338
339
339
/**
You can’t perform that action at this time.
0 commit comments