-
Notifications
You must be signed in to change notification settings - Fork 20
Angular Router - navigation event fired twice #29
Comments
Has anyone looked into this? I believe I'm getting the same double firing behavior, any ideas for how to fix this? |
Can someone provide a simple reproduction of this issue? |
Same problem here, to reproduce just listen NavigationStart event:
|
This appears to still be happening. Is there any workaround (besides designing anything that listens to this to be able to fire twice without issue) or any plan to fix this? |
I came to this issue having a bug with the back button, that if I do this A->B->C and click back, it loops betwen C and B instead of going back to A. I am pretty sure it is related to this issue of the NavigationStart being fired twice. Any update? |
No updates. Version 2.x of |
But this is still happening in Angular 5.x the one I have upgraded when I detected this thing. |
@aerlijman can you share the code you are using to listen to the event? We discovered that if we use any of the events that get called by the routing process (ngOnInit, ngOnInitFinished, etc) that the method will get called once during the normal routing process and again when the listener hits |
In ngOnInit I have
|
Hi, I am facing similar issue with I have tried to isolate the issue here: https://github.com/felikf/angular-router-double-navigation The interesting part is in router.effects.ts:
@brandonroberts please see this |
I got around this by making sure to unsubscribe at the appropriate times. in my case it was
|
I'm seeing one subscription to
Is this really a bug, or am I missing something? |
Oh. I figured out my problem: https://stackoverflow.com/a/50808849/1253298 I should have been using NavigationEnd, not ActivationEnd. |
Hi,
when route is changed with Angulars Route, then the store will create new navigation event, which will result in two same router events.
For example:
After you click that link, router will do the navigation, which is then pickup by the listener from connect.ts as stored state is different, but it will also call the Router to change location to the same url, resulting into two same navigation events.
The text was updated successfully, but these errors were encountered: