@@ -126,11 +126,21 @@ export class NSLocationStrategy extends LocationStrategy {
126
126
this . currentUrlTree = urlSerializer . parse ( url ) ;
127
127
const urlTreeRoot = this . currentUrlTree . root ;
128
128
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.
129
131
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 ;
134
144
return ;
135
145
}
136
146
@@ -543,21 +553,12 @@ export class NSLocationStrategy extends LocationStrategy {
543
553
}
544
554
545
555
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
-
555
556
const pathByOutlets = this . getPathByOutlets ( segmentGroup ) ;
556
557
const newOutlet = new Outlet ( outletKey , pathByOutlets , modalNavigation ) ;
557
558
558
559
const locationState : LocationState = {
559
560
segmentGroup : segmentGroup ,
560
- isRootSegmentGroup : isRootSegmentGroup ,
561
+ isRootSegmentGroup : false ,
561
562
isPageNavigation : true // It is a new OutletNode.
562
563
} ;
563
564
0 commit comments