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
If you are using webpack, you can use the url polyfill module which comes bundled, along with the Angular Router module.
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as url from 'url'
@Component({
selector: 'app-component',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
public constructor(public readonly router: Router) {}
public ngOnInit() {
const urlInfo = url.parse(this.router.url)
console.log(urlInfo.pathname)
}
}