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 {
1111 Component ,
1212 Directive ,
1313 Inject ,
14+ InjectionToken ,
1415 Injector ,
1516 TemplateRef ,
1617 ViewChild ,
@@ -125,6 +126,15 @@ describe('Dialog', () => {
125126 ) ;
126127 } ) ;
127128
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+
128138 it ( 'should open a dialog with a component and no ViewContainerRef' , ( ) => {
129139 let dialogRef = dialog . open ( PizzaMsg ) ;
130140
Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ export class Dialog implements OnDestroy {
333333 } ) ;
334334 }
335335
336- return Injector . create ( { parent : userInjector || this . _injector , providers} ) ;
336+ return Injector . create ( { parent : config . injector || userInjector || this . _injector , providers} ) ;
337337 }
338338
339339 /**
You can’t perform that action at this time.
0 commit comments