In angular2 rc1, I subscribe to a route change:
this.router.changes.subscribe( () => { console.log(this.location.path()); });
How can I sign up for a route change in angular2 rc3? router.changes no longer exists.
constructor(router:Router) { router.events.subscribe(event:Event => { if(event instanceof NavigationStart) { } // NavigationEnd // NavigationCancel // NavigationError // RoutesRecognized } }
or
constructor(router:Router) { router.events.forEach(event:Event => {
constructor(private router: Router) { this.router.events.subscribe(event => { if (event.constructor.name === 'NavigationStart') { console.log(event.url); } }); }