Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named Router-Outlets are not navigating with window url [Hopefully Simple] #19001

Closed
wakawaka54 opened this issue Sep 1, 2017 · 2 comments
Closed

Comments

@wakawaka54
Copy link

wakawaka54 commented Sep 1, 2017

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When I navigate to / the correct NavbarComponent shows up on the router-outlet named 'navbar'. However, when I navigate to /app/dashboard the AppCentralNavbarComponent does not show up on the router-outlet named 'navbar', instead the error:

ERROR Error: Uncaught (in promise): Error: Cannot activate an already activated outlet
Error: Cannot activate an already activated outlet

is thrown.

app.routing.ts

export const routes: Routes = [
  { path: '', component: NavbarComponent, outlet: 'navbar' },
  { path: 'account', loadChildren: './features/account/account.module#AccountModule' },
  { path: 'app', loadChildren: './features/app-central.module#AppCentralModule' },
  { path: '*', component: HomeComponent }
];

app-central.routing.ts

export const routes: Routes = [
  { path: 'dashboard', component: DashboardComponent },
  { path: '', component: AppCentralNavbarComponent, outlet: 'navbar' },
  { path: '', component: AppCentralSidebarComponent, outlet: 'sidebar' }
];

standard-layout.component.html

<div>
  <router-outlet name="navbar"></router-outlet>
</div>
<div class="container-fluid">
  <o-app-alert></o-app-alert>
  <o-sidebar></o-sidebar>
  <o-body></o-body>
  <router-outlet name="popup"></router-outlet>
</div>

Expected behavior

Expected behavior is to navigate router-outlets regardless of outlet name to the correct component based on the window path.

Minimal reproduction of the problem with instructions

  • STEPS TO REPRODUCE *
  • Create routing as above in app.routing.ts.
  • Create a submodule as above in app-central.routing.ts
  • Navigate to /app/dashboard and see if the navbar outlet changes.

What is the motivation / use case for changing the behavior?

Need to change the navbar based on the URL of the open window. The navbar will need to be different per the route.

Environment


Angular version: ^4.0.0

Browser:
- [x ] Chrome (desktop) version 63
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
@wakawaka54 wakawaka54 changed the title Router not navigating with router-outlets Named Router-Outlets are not navigating with window url Sep 1, 2017
@wakawaka54 wakawaka54 changed the title Named Router-Outlets are not navigating with window url Named Router-Outlets are not navigating with window url [Router] Sep 1, 2017
@wakawaka54 wakawaka54 changed the title Named Router-Outlets are not navigating with window url [Router] Named Router-Outlets are not navigating with window url [Hopefully Simple] Sep 1, 2017
@wakawaka54
Copy link
Author

I figured it out, I had to make the Navbar route more restrictive because it was being picked up even with /app/dashboard. The new app.routing.ts is as follows:

export const routes: Routes = [
  { path: 'account/*', component: NavbarComponent, outlet: 'navbar' },
  { path: '', component: NavbarComponent, pathMatch: 'full', outlet: 'navbar' },
  { path: 'account', loadChildren: './features/account/account.module#AccountModule' },
  { path: 'app', loadChildren: './features/app-central.module#AppCentralModule' },
  { path: '*', component: HomeComponent }
];

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant