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
Angular 4.x and above :
This can be achieved using url property of ActivatedRoute class as below,
this.activatedRoute.url.subscribe(url =>{
console.log(url);
});
Note:
That you need to import and inject the provider from angular/router
package
import { ActivatedRoute } from '@angular/router`
and
constructor(private activatedRoute : ActivatedRoute){ }