@@ -126,11 +126,21 @@ export class NSLocationStrategy extends LocationStrategy {
126126 this . currentUrlTree = urlSerializer . parse ( url ) ;
127127 const urlTreeRoot = this . currentUrlTree . root ;
128128
129+ // Handle case where the user declares a component at path "/".
130+ // The url serializer doesn't parse this url as having a primary outlet.
129131 if ( ! Object . keys ( urlTreeRoot . children ) . length ) {
130- // Handle case where the user declares a component at path "/".
131- // The url serializer doesn't parse this url as having a primary outlet.
132- const rootOutlet = this . createOutlet ( "primary" , null , null ) ;
133- this . currentOutlet = rootOutlet ;
132+ const segmentGroup = this . currentUrlTree && this . currentUrlTree . root ;
133+ const outletKey = this . getSegmentGroupFullPath ( segmentGroup ) + "primary" ;
134+ const outlet = this . findOutletByKey ( outletKey ) ;
135+
136+ if ( outlet && this . updateStates ( outlet , segmentGroup ) ) {
137+ this . currentOutlet = outlet ; // If states updated
138+ } else if ( ! outlet ) {
139+ const rootOutlet = this . createOutlet ( "primary" , segmentGroup , null ) ;
140+ this . currentOutlet = rootOutlet ;
141+ }
142+
143+ this . currentOutlet . peekState ( ) . isRootSegmentGroup = true ;
134144 return ;
135145 }
136146
@@ -543,21 +553,12 @@ export class NSLocationStrategy extends LocationStrategy {
543553 }
544554
545555 private createOutlet ( outletKey : string , segmentGroup : any , parent : Outlet , modalNavigation ?: number ) : Outlet {
546- let isRootSegmentGroup : boolean = false ;
547-
548- if ( ! segmentGroup ) {
549- // Handle case where the user declares a component at path "/".
550- // The url serializer doesn't parse this url as having a primary outlet.
551- segmentGroup = this . currentUrlTree && this . currentUrlTree . root ;
552- isRootSegmentGroup = true ;
553- }
554-
555556 const pathByOutlets = this . getPathByOutlets ( segmentGroup ) ;
556557 const newOutlet = new Outlet ( outletKey , pathByOutlets , modalNavigation ) ;
557558
558559 const locationState : LocationState = {
559560 segmentGroup : segmentGroup ,
560- isRootSegmentGroup : isRootSegmentGroup ,
561+ isRootSegmentGroup : false ,
561562 isPageNavigation : true // It is a new OutletNode.
562563 } ;
563564
0 commit comments