File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,17 +47,18 @@ import { Route } from '@angular/router';
4747 */
4848export function setupInjectionContextForLoadChildren (
4949 route : Route ,
50- injectorDefault ?: Injector ,
50+ injectorDefault ?: ( ) => Injector ,
5151) : Route {
52- let injector : Injector | undefined = injectorDefault ;
52+ let injectorRoute : Injector | undefined ;
5353 const injectorInitializer = ( ) => {
54- injector = inject ( Injector ) ;
54+ injectorRoute = inject ( Injector ) ;
5555 } ;
5656
5757 const transformRoute = ( child : Route ) => {
5858 if ( ! child . loadChildren ) return child ;
5959 const loadChildren = child . loadChildren ;
6060 child . loadChildren = ( ...args ) => {
61+ const injector = injectorRoute ?? injectorDefault ?.( ) ;
6162 if ( ! injector ) throw new Error ( 'missing injector for loadChildren' ) ;
6263 return runInInjectionContext ( injector , ( ) => loadChildren ( ...args ) ) ;
6364 } ;
You can’t perform that action at this time.
0 commit comments