File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -66,21 +66,22 @@ export class DomPortalOutlet extends BasePortalOutlet {
6666 if ( ( typeof ngDevMode === 'undefined' || ngDevMode ) && ! this . _appRef ) {
6767 throw Error ( 'Cannot attach component portal to outlet without an ApplicationRef.' ) ;
6868 }
69+ const appRef = this . _appRef ! ;
6970
7071 const elementInjector = portal . injector || this . _defaultInjector || Injector . NULL ;
71- const environmentInjector = elementInjector . get ( EnvironmentInjector , this . _appRef ! . injector ) ;
72+ const environmentInjector = elementInjector . get ( EnvironmentInjector , appRef . injector ) ;
7273 componentRef = createComponent ( portal . component , {
7374 elementInjector,
7475 environmentInjector,
7576 projectableNodes : portal . projectableNodes || undefined ,
7677 } ) ;
7778
78- this . _appRef ! . attachView ( componentRef . hostView ) ;
79+ appRef . attachView ( componentRef . hostView ) ;
7980 this . setDisposeFn ( ( ) => {
8081 // Verify that the ApplicationRef has registered views before trying to detach a host view.
8182 // This check also protects the `detachView` from being called on a destroyed ApplicationRef.
82- if ( this . _appRef ! . viewCount > 0 ) {
83- this . _appRef ! . detachView ( componentRef . hostView ) ;
83+ if ( appRef . viewCount > 0 ) {
84+ appRef . detachView ( componentRef . hostView ) ;
8485 }
8586 componentRef . destroy ( ) ;
8687 } ) ;
Original file line number Diff line number Diff line change @@ -643,9 +643,7 @@ describe('Portals', () => {
643643 ) ;
644644
645645 @Component ( { template : '' } )
646- class ChildComponent {
647- readonly injector = inject ( Injector ) ;
648- }
646+ class ChildComponent { }
649647
650648 const component = createComponent ( ChildComponent , {
651649 environmentInjector : childEnvironment ,
You can’t perform that action at this time.
0 commit comments