Ability to check for previous route with router.events.subscribe
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior The NavigationStart event object only returns the target url.
Expected/desired behavior Have the event also return the previous url
What is the motivation / use case for changing the behavior? I am having to call window.scrollTo(0,0) on every route call so that the new route doesn’t load at a random point on the page. But I don’t want this to happen on every route, and in some cases I want this to not happen when the routes are both children of the same component route.
Please tell us about your environment:
- Angular version: 2.0.0-rc.5
- Browser: [all ]
- Language: [all]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:31 (5 by maintainers)
Top Results From Across the Web
How to determine previous page URL in Angular?
You can subscribe to route changes and store the current event so you can use it when the next happens previousUrl: string; constructor(router:...
Read more >How to access the previous route in your Angular app
First create a new service PreviousRouteService . If you're using the Angular CLI , use the command ng generate service previous-route and add ......
Read more >Subscribing To Router Events In Angular - Upmostly
It's pretty common in an Angular project to add the ability to “listen” for router events. That is, know that a user is...
Read more >Accessing the Previous URL in Angular | by Jacob Neterer
Then, you will subscribe to router events and filter those events by the NavigationEnd type event. This gives us access to the current...
Read more >Using Router Events To Detect Back And Forward Browser ...
To explore this Router behavior, I created a simple demo in which you can navigate between three routes, each of which has three...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After following your recommendation. This is my working code.
Thank you very much!