-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Description
I have a routerLink URL that can change over time, but when the URL changes, routerLinkActive is not re-evaluated.
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report
[ ] Feature request
[ ] 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
Change a routerLink URL to match/not match the current URL. routerLinkActive class is not applied/removed.
Expected behavior
routerLinkActive is re-evaluated when its corresponding routerLink is updated.
Minimal reproduction of the problem with instructions
Click "link a" or "link b" to make them active, then click the switchLinks button to change the URLs. Nothing changes.
http://plnkr.co/edit/DHn4my9uAKJSIQSTIm1g?p=preview
What is the motivation / use case for changing the behavior?
I have multiple departments managed by the same UI, with department name as a variable in the URL. When the user switches departments, and the on screen links or URL is changed, the UI doesn't update the routerLinkActive.
I think it's because ContentChildren.changes doesn't fire if the contents of a directive is changed, only when directives are added or removed.:
https://github.com/angular/angular/blob/master/packages/router/src/directives/router_link_active.ts#L106
Maybe it's too bad for performance to fix this?
Environment
Angular version: 4.3
Mac
Browser:
- [x ] Chrome (desktop) version 59
- 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