0 votes
in Angular by
How do you get the current route?

1 Answer

0 votes
by

In Angular, there is an url property of router package to get the current route. You need to follow the below few steps,

  1. Import Router from @angular/router
  import { Router } from '@angular/router';
  1. Inject router inside constructor
constructor(private router: Router ) {

}
  1. Access url parameter
  console.log(this.router.url); //  /routename
...