I need to get my current route without params in Angular 2, I found a way to get the current route with params as follows:
this.router.url
this could help you:
Import Router:
import { Router } from '@angular/router';
Signature in the constructor:
constructor(private _router: Router) {}
Check the _router events property:
this._router.events
.subscribe(
(url:any) => {
let _ruta = "";
url.url.split("/").forEach(element => {
if(element!=="" && _ruta==="")
_ruta="/"+element;
});
console.log("route: "+_ruta); //<<<---- Root path
console.log("to URL:"+url.url); //<<<---- Destination URL
console.log("from URL:"+this._router.url);//<<<---- Current URL
});