Error Navigating to Sibling After Navigation in Named Router Outlet












0















I've run into what I believe is a bug in Angular 6/7 routing and I am looking to find a workaround if it is a bug, or fix the routing if it's not.



Navigation to a sibling route fails after navigating to a route that includes a named router outlet which is a child of one of sibling routes.



Given the routing configuration, below, and starting with a URL of /1/documents:




  1. If link to "other" is triggered from ModuleComponent, URL changes to /1/other and component is loaded successfully. This is working as expected

  2. If a component is loaded into the named outlet (i.e. URL changed to /1/(documents//outlet:test)) and then the same link from (1) is used, then no navigation occurs and an error is logged in the console.


The expectation would be for (2) to result in the navigation completing successfully and for OtherComponent to be displayed.



Another note: Problem persists even if the named router outlet portion of the route is removed (i.e. [{ outlets: { outlet: null } }])



Routing configuration:



export const appRoutes: Routes = [{
path: '', component: AppOutletComponent,
children: [
{ path: ':id/other', component: OtherComponent },
{
path: ':id', component: ModuleComponent, pathMatch: 'prefix',
children: [
{ path: '', redirectTo: 'documents', pathMatch: 'full' },
{ path: 'documents', component: DocumentsComponent },
{
path: 'test',
outlet: 'outlet',
component: OutletChildComponent
}
]
}
]
}];


Here is the error that results:



ERROR
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '1'
Error: Cannot match any routes. URL Segment: '1'
at ApplyRedirects.noMatchError (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2520:20)
at CatchSubscriber.eval [as selector] (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2501:33)
at CatchSubscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/catchError.js:48:31)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at TapSubscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/tap.js:75:26)


I have created two small apps on Stackblitz that demonstrate the issue:




  • With straight app and child components:


    • https://outlet-routing-bug-shared-minimal.stackblitz.io


    • https://stackblitz.com/edit/outlet-routing-bug-shared-minimal



  • Slightly different behaviour when in lazy-loaded module (this is what I am actually trying to achieve in my app, but tried to pare it down):


    • https://outlet-routing-bug-shared.stackblitz.io

    • https://stackblitz.com/edit/outlet-routing-bug-shared




Environment:




  • Angular 7.2.1 (also occurs in latest 6)


Hopefully I am not simply misunderstanding or abusing the routing system...



Logged bug with Angular project: https://github.com/angular/angular/issues/28189










share|improve this question

























  • Can you share the stackblitz link where I can see the code?

    – Aragorn
    Jan 18 at 17:50











  • @Aragorn There are two links in the original question...

    – cmatthews.dickson
    Jan 18 at 20:03








  • 1





    Saw those links and tested the error, I want the link to IDE where I can see the code, those links just take me to to browser where I can only see the behavior.

    – Aragorn
    Jan 18 at 20:25











  • Does this sound like your issue: github.com/angular/angular/issues/27215

    – DeborahK
    Jan 18 at 20:42











  • @Aragorn stackblitz.com/edit/outlet-routing-bug-shared-minimal and stackblitz.com/edit/outlet-routing-bug-shared

    – cmatthews.dickson
    Jan 18 at 21:24


















0















I've run into what I believe is a bug in Angular 6/7 routing and I am looking to find a workaround if it is a bug, or fix the routing if it's not.



Navigation to a sibling route fails after navigating to a route that includes a named router outlet which is a child of one of sibling routes.



Given the routing configuration, below, and starting with a URL of /1/documents:




  1. If link to "other" is triggered from ModuleComponent, URL changes to /1/other and component is loaded successfully. This is working as expected

  2. If a component is loaded into the named outlet (i.e. URL changed to /1/(documents//outlet:test)) and then the same link from (1) is used, then no navigation occurs and an error is logged in the console.


The expectation would be for (2) to result in the navigation completing successfully and for OtherComponent to be displayed.



Another note: Problem persists even if the named router outlet portion of the route is removed (i.e. [{ outlets: { outlet: null } }])



Routing configuration:



export const appRoutes: Routes = [{
path: '', component: AppOutletComponent,
children: [
{ path: ':id/other', component: OtherComponent },
{
path: ':id', component: ModuleComponent, pathMatch: 'prefix',
children: [
{ path: '', redirectTo: 'documents', pathMatch: 'full' },
{ path: 'documents', component: DocumentsComponent },
{
path: 'test',
outlet: 'outlet',
component: OutletChildComponent
}
]
}
]
}];


Here is the error that results:



ERROR
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '1'
Error: Cannot match any routes. URL Segment: '1'
at ApplyRedirects.noMatchError (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2520:20)
at CatchSubscriber.eval [as selector] (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2501:33)
at CatchSubscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/catchError.js:48:31)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at TapSubscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/tap.js:75:26)


I have created two small apps on Stackblitz that demonstrate the issue:




  • With straight app and child components:


    • https://outlet-routing-bug-shared-minimal.stackblitz.io


    • https://stackblitz.com/edit/outlet-routing-bug-shared-minimal



  • Slightly different behaviour when in lazy-loaded module (this is what I am actually trying to achieve in my app, but tried to pare it down):


    • https://outlet-routing-bug-shared.stackblitz.io

    • https://stackblitz.com/edit/outlet-routing-bug-shared




Environment:




  • Angular 7.2.1 (also occurs in latest 6)


Hopefully I am not simply misunderstanding or abusing the routing system...



Logged bug with Angular project: https://github.com/angular/angular/issues/28189










share|improve this question

























  • Can you share the stackblitz link where I can see the code?

    – Aragorn
    Jan 18 at 17:50











  • @Aragorn There are two links in the original question...

    – cmatthews.dickson
    Jan 18 at 20:03








  • 1





    Saw those links and tested the error, I want the link to IDE where I can see the code, those links just take me to to browser where I can only see the behavior.

    – Aragorn
    Jan 18 at 20:25











  • Does this sound like your issue: github.com/angular/angular/issues/27215

    – DeborahK
    Jan 18 at 20:42











  • @Aragorn stackblitz.com/edit/outlet-routing-bug-shared-minimal and stackblitz.com/edit/outlet-routing-bug-shared

    – cmatthews.dickson
    Jan 18 at 21:24
















0












0








0








I've run into what I believe is a bug in Angular 6/7 routing and I am looking to find a workaround if it is a bug, or fix the routing if it's not.



Navigation to a sibling route fails after navigating to a route that includes a named router outlet which is a child of one of sibling routes.



Given the routing configuration, below, and starting with a URL of /1/documents:




  1. If link to "other" is triggered from ModuleComponent, URL changes to /1/other and component is loaded successfully. This is working as expected

  2. If a component is loaded into the named outlet (i.e. URL changed to /1/(documents//outlet:test)) and then the same link from (1) is used, then no navigation occurs and an error is logged in the console.


The expectation would be for (2) to result in the navigation completing successfully and for OtherComponent to be displayed.



Another note: Problem persists even if the named router outlet portion of the route is removed (i.e. [{ outlets: { outlet: null } }])



Routing configuration:



export const appRoutes: Routes = [{
path: '', component: AppOutletComponent,
children: [
{ path: ':id/other', component: OtherComponent },
{
path: ':id', component: ModuleComponent, pathMatch: 'prefix',
children: [
{ path: '', redirectTo: 'documents', pathMatch: 'full' },
{ path: 'documents', component: DocumentsComponent },
{
path: 'test',
outlet: 'outlet',
component: OutletChildComponent
}
]
}
]
}];


Here is the error that results:



ERROR
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '1'
Error: Cannot match any routes. URL Segment: '1'
at ApplyRedirects.noMatchError (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2520:20)
at CatchSubscriber.eval [as selector] (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2501:33)
at CatchSubscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/catchError.js:48:31)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at TapSubscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/tap.js:75:26)


I have created two small apps on Stackblitz that demonstrate the issue:




  • With straight app and child components:


    • https://outlet-routing-bug-shared-minimal.stackblitz.io


    • https://stackblitz.com/edit/outlet-routing-bug-shared-minimal



  • Slightly different behaviour when in lazy-loaded module (this is what I am actually trying to achieve in my app, but tried to pare it down):


    • https://outlet-routing-bug-shared.stackblitz.io

    • https://stackblitz.com/edit/outlet-routing-bug-shared




Environment:




  • Angular 7.2.1 (also occurs in latest 6)


Hopefully I am not simply misunderstanding or abusing the routing system...



Logged bug with Angular project: https://github.com/angular/angular/issues/28189










share|improve this question
















I've run into what I believe is a bug in Angular 6/7 routing and I am looking to find a workaround if it is a bug, or fix the routing if it's not.



Navigation to a sibling route fails after navigating to a route that includes a named router outlet which is a child of one of sibling routes.



Given the routing configuration, below, and starting with a URL of /1/documents:




  1. If link to "other" is triggered from ModuleComponent, URL changes to /1/other and component is loaded successfully. This is working as expected

  2. If a component is loaded into the named outlet (i.e. URL changed to /1/(documents//outlet:test)) and then the same link from (1) is used, then no navigation occurs and an error is logged in the console.


The expectation would be for (2) to result in the navigation completing successfully and for OtherComponent to be displayed.



Another note: Problem persists even if the named router outlet portion of the route is removed (i.e. [{ outlets: { outlet: null } }])



Routing configuration:



export const appRoutes: Routes = [{
path: '', component: AppOutletComponent,
children: [
{ path: ':id/other', component: OtherComponent },
{
path: ':id', component: ModuleComponent, pathMatch: 'prefix',
children: [
{ path: '', redirectTo: 'documents', pathMatch: 'full' },
{ path: 'documents', component: DocumentsComponent },
{
path: 'test',
outlet: 'outlet',
component: OutletChildComponent
}
]
}
]
}];


Here is the error that results:



ERROR
Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '1'
Error: Cannot match any routes. URL Segment: '1'
at ApplyRedirects.noMatchError (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2520:20)
at CatchSubscriber.eval [as selector] (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/@angular/router@7.0.1/bundles/router.umd.js:2501:33)
at CatchSubscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/catchError.js:48:31)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at MapSubscriber.Subscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:93:26)
at MapSubscriber.Subscriber.error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/Subscriber.js:73:18)
at TapSubscriber._error (https://outlet-routing-bug-shared-minimal.stackblitz.io/turbo_modules/rxjs@6.3.3/internal/operators/tap.js:75:26)


I have created two small apps on Stackblitz that demonstrate the issue:




  • With straight app and child components:


    • https://outlet-routing-bug-shared-minimal.stackblitz.io


    • https://stackblitz.com/edit/outlet-routing-bug-shared-minimal



  • Slightly different behaviour when in lazy-loaded module (this is what I am actually trying to achieve in my app, but tried to pare it down):


    • https://outlet-routing-bug-shared.stackblitz.io

    • https://stackblitz.com/edit/outlet-routing-bug-shared




Environment:




  • Angular 7.2.1 (also occurs in latest 6)


Hopefully I am not simply misunderstanding or abusing the routing system...



Logged bug with Angular project: https://github.com/angular/angular/issues/28189







angular routing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







cmatthews.dickson

















asked Jan 18 at 16:08









cmatthews.dicksoncmatthews.dickson

282611




282611













  • Can you share the stackblitz link where I can see the code?

    – Aragorn
    Jan 18 at 17:50











  • @Aragorn There are two links in the original question...

    – cmatthews.dickson
    Jan 18 at 20:03








  • 1





    Saw those links and tested the error, I want the link to IDE where I can see the code, those links just take me to to browser where I can only see the behavior.

    – Aragorn
    Jan 18 at 20:25











  • Does this sound like your issue: github.com/angular/angular/issues/27215

    – DeborahK
    Jan 18 at 20:42











  • @Aragorn stackblitz.com/edit/outlet-routing-bug-shared-minimal and stackblitz.com/edit/outlet-routing-bug-shared

    – cmatthews.dickson
    Jan 18 at 21:24





















  • Can you share the stackblitz link where I can see the code?

    – Aragorn
    Jan 18 at 17:50











  • @Aragorn There are two links in the original question...

    – cmatthews.dickson
    Jan 18 at 20:03








  • 1





    Saw those links and tested the error, I want the link to IDE where I can see the code, those links just take me to to browser where I can only see the behavior.

    – Aragorn
    Jan 18 at 20:25











  • Does this sound like your issue: github.com/angular/angular/issues/27215

    – DeborahK
    Jan 18 at 20:42











  • @Aragorn stackblitz.com/edit/outlet-routing-bug-shared-minimal and stackblitz.com/edit/outlet-routing-bug-shared

    – cmatthews.dickson
    Jan 18 at 21:24



















Can you share the stackblitz link where I can see the code?

– Aragorn
Jan 18 at 17:50





Can you share the stackblitz link where I can see the code?

– Aragorn
Jan 18 at 17:50













@Aragorn There are two links in the original question...

– cmatthews.dickson
Jan 18 at 20:03







@Aragorn There are two links in the original question...

– cmatthews.dickson
Jan 18 at 20:03






1




1





Saw those links and tested the error, I want the link to IDE where I can see the code, those links just take me to to browser where I can only see the behavior.

– Aragorn
Jan 18 at 20:25





Saw those links and tested the error, I want the link to IDE where I can see the code, those links just take me to to browser where I can only see the behavior.

– Aragorn
Jan 18 at 20:25













Does this sound like your issue: github.com/angular/angular/issues/27215

– DeborahK
Jan 18 at 20:42





Does this sound like your issue: github.com/angular/angular/issues/27215

– DeborahK
Jan 18 at 20:42













@Aragorn stackblitz.com/edit/outlet-routing-bug-shared-minimal and stackblitz.com/edit/outlet-routing-bug-shared

– cmatthews.dickson
Jan 18 at 21:24







@Aragorn stackblitz.com/edit/outlet-routing-bug-shared-minimal and stackblitz.com/edit/outlet-routing-bug-shared

– cmatthews.dickson
Jan 18 at 21:24














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257597%2ferror-navigating-to-sibling-after-navigation-in-named-router-outlet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257597%2ferror-navigating-to-sibling-after-navigation-in-named-router-outlet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage