In Angular, there is an url
property of router package to get the current route. You need to follow the below few steps,
- Import Router from @angular/router
import { Router } from '@angular/router';
- Inject router inside constructor
constructor(private router: Router ) {
}
- Access url parameter
console.log(this.router.url); // /routename