Route change doesn't trigger Location.subscribe
When changing routes using new router with angular 2.0.0.rc1, Location.subscribe never gets triggered.
It should trigger the subscription, since it's the only method available to check for URL changes in new router.
Steps to reproduce and a minimal demo of the problem http://plnkr.co/edit/hvtCJa?p=preview
What steps should we try in your demo to see the problem?
Click on Home/ List screen should poplate the text next to "Debug:"
Current behavior location.susbcribe not being called on route change
Expected/desired behavior location.susbcribe should be called on route change
Other information similar issue : https://github.com/angular/angular/issues/8630
Location.subscribe only emits on window.popstate aka history navigation.
You can subscribe on router.changes
constructor(router: Router, location: Location) {
router.changes.subscribe(() => console.log(location.path()))
}
Sadly the router pushStates the url immediately after history.back and prevents more then one history navigation attempt (https://github.com/angular/angular/blob/master/modules/@angular/router/src/router.ts#L151). Don't know the reasoning behind that.
@sod Yes I tested this is getting called on history navigation. But shouldn't this be called for when route changes as well.
Are there any news from the google team about this? It looks like it is affecting some projects related to analytics that detects this change. How we can help?
This has been raised now deprecated router. The latest one @angular/router version 3.0.0.rc1 has no such limitation.
You can subscribe to' router.events'. [See ] [1]
[1] https://angular.io/docs/ts/latest/api/router/index/Router-class.html#!#events-anchor
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.