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
1 | import { Router } from '@angular/router'; |
2. Inject router inside constructor
1 2 3 | constructor(private router: Router ) { } |
3. Access url parameter
1 | console.log(this.router.url); // /routename |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.