In my app there is more than one way to route to a particular resource, for example, I got breadcrumbs in order to be able to navigate more freely through a hierarchy of items
SectionA > SectionB > SectionC
where SectionA
has id=1
and so on. At the same time I got a routerLink
in my side menu to the currently selected item, which in the above example would point to SectionC
(id=3
). I keep these synchronous by emitting an event when someone clicks on a breadcrumb and then binding the id
from the event to the routerLink
in my side menu:
<li>
<a [routerLink]="['/section, section? section.id : 0]" [routerLinkActive]="['active']"></a>
</li>
This way, if the user navigates away from that component they can come back to the same state by just clicking on the button in the side menu (instead of having to navigate to their target section from scratch).
This does actually work fine, however, if I navigate through the breadcrumbs (and thus am using the binding to section
from above) routerLinkActive
doesn't fire although the current URL and the URL on the side menu button are identical.
Only if I click the side menu button directly is the active
class applied, it doesn't work through the binding.
It works for URLs without parameters (no binding there), so I guess it's to do with Angular's change checking.
Question is, is this intended behaviour and if so, what am I supposed to do in order to get this to work anyway?