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

router-link-active not working for nested routes #5334

Closed
choeller opened this issue Nov 17, 2015 · 5 comments
Closed

router-link-active not working for nested routes #5334

choeller opened this issue Nov 17, 2015 · 5 comments

Comments

@choeller
Copy link
Contributor

When working with nested routes, all links to routes under a common root-path get the router-link-active class. E.g having two links like this:

<li>
    <a [router-link]="['/Tasks', 'List']" class="link">Task Overview</a>
</li>
<li>
     <a [router-link]="['/Tasks', 'NewTask']" class="link">New Task</a>
</li>

navigating to "#/tasks/lists" results in the following DOM:

<li _ngcontent-sno-1="">
      <a class="link router-link-active" _ngcontent-sno-1="" href="#/tasks/list">Task Overview</a>
</li>

<li _ngcontent-sno-1="">
     <a class="link router-link-active" _ngcontent-sno-1="" href="#/tasks/new">New Task</a>
</li>
@choeller
Copy link
Contributor Author

So here is a plnkr demonstrating the behaviour: http://plnkr.co/edit/wAzoCIWB23KQLGWw1EGB?p=preview

@zoechi
Copy link
Contributor

zoechi commented Jun 13, 2016

I think this can be closed. This router is deprecated and this works differently in the new router.

@choeller
Copy link
Contributor Author

Yeah, as of https://github.com/angular/vladivostok/issues/24 there might be a new solution for this, so I'll close this one...

@cchapman900
Copy link

I had a similar issue where my routerLinkActive wasn't being activated because I had my routerLink as /projects/{{project?._id}} in which case the project was originally starting as null.

I wrapped everything in a <div *ngIf="project"> and removed the ? and not it's working correctly.

@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 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants