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
[routerLink] with async/observable property assignment does not re-evaluate [routerLinkActive] when the observable emits a new value. #13865
Comments
Are you sure the two tickets are describing the same issue? This isn't an issue where 'active' isn't updated when the page route changes (which is what I understand from the other ticket) - this is an issue where you stay on the same page, but change the value of a link via an observable. |
That is my plunkr, it has unrelated code but you can repro the same buggy behavior: https://plnkr.co/edit/C9W0pHvy27J83m25YUOJ?p=preview These are the steps to retrace the problem:
|
Any news on this after 2 months? My application menu is still not yet activated :/ |
@bastienJS still not fixed. A work-around I'm using is to add a (click) event handler to invoke navigation within the navigation component... it sucks but it works. in the interim. |
@josh-sachs You want to tell me that within my component containing the brokenk Links I should do a router.navigate(...) to the url I am already on? Hm yeah loading data twice and its silly, but thanks for the workaround I will have to use it! |
The workaround doesn't work for me: I have a path like Everything works fine except for the |
@netmikey i guess you are creating new observable on every change detection. Make sure it is single object. Observe no function call |
@bastienJS The workaround I proposed was to use (click) handler instead of [routerLink]. If you navigate to a url you are already on - nothing happens... no component is re-initialized.
|
@josh-sachs Thanks now I understand it. |
Any news on this? It seems like this is still present in Angular 4.1.0. |
I'm using the following workaround, based on the fact that the RouterLinkActiveOptions can also trigger updates:
with:
Whenever the route changes (can be routing events):
|
@timvdalen Thank you, put an end to many hours of frustration. You can make the workaround less ugly by just re-assigning the actual setting you want |
Even renaming rlao to rlmao did not work :/ I just wanted to activate the link for test purpose for any event this.router.events.subscribe(event => { What do I wrong? I hit F5 and the whole site reloads, but the current route in the browser does not trigger the RouterLink to be activated, only when I click it... |
I can confirm this bug. My workaround was adding
|
Contrary to my previous statement the rlao trick does work! - in my plunker - just not in my local app on the computer. I moved now the plunkr piece by piece to my local app with a new angular cli setup project and it still works!!! Somehow my local app was broken but I could not find out why... I bet this bug will survive ng 5.1 :P it must be really lots of effort to fix this then... |
Any news on this fix? i can't seem to get any of those workarounds to work for me |
Any update on this? Is there an ETA for a fix? |
yes => NEVER :P |
Duplicate of #18469 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
[routerLink] with async/observable property assignment does not re-evaluate [routerLinkActive] when the observable emits a new value.
Expected behavior
When the value emitted to [routerLink] changes, [routerLinkActive] should re-evaluate against the newly emitted value whether or not the link is "active."
Minimal reproduction of the problem with instructions
<a class="waves-effect" [routerLink]="observable$ | async" [routerLinkActive]="['active']" [routerLinkActiveOptions]="{ exact: true }">LINK
the application of the "active" class will not be re-evaluated when a new value is emitted by observable$.
e.g.
obervable$ = Observable.interval(1000).map(i => ['/page/' + i])
If you are on /page/0 link will be active on first emission, but will not go inactive once i > 1.
What is the motivation / use case for changing the behavior?
Using observables with routerLink should work.
Please tell us about your environment:
Chrome 55m, Windows 10
2.4.1
Language: [all | TypeScript X.X | ES6/7 | ES5]
TypeScript 2.1.4.0
Node (for AoT issues):
node --version
=The text was updated successfully, but these errors were encountered: