I am looking to detect a route change in my AppComponent
.
Thereafter I will check the global user token to see if he is logged in. Then I can redirect t
The answers here are correct for router-deprecated. For the latest version of router:
this.router.changes.forEach(() => {
// Do whatever in here
});
or
this.router.changes.subscribe(() => {
// Do whatever in here
});
To see the difference between the two, please check out this SO question.
Edit
For the latest you must do:
this.router.events.subscribe(event: Event => {
// Handle route change
});