How can I get current route

0 votes
I know window.location can be option but the problem with window.location is that if in the future, they want to implement server-side rendering, they will face some difficulties since window does not exist on the Node.js server, but they need to use the Angular standard methods to access the route and they'll be fine both on server and browser.

So is there is another possible way to find?
Sep 14, 2020 in Angular by Ava
• 120 points
649 views

1 answer to this question.

0 votes

Hello @Ava,

Try this

this.router.events.filter((event: any) => event instanceof NavigationEnd).subscribe(event => { console.log('this is what your looking for ', event.url); });

answered Sep 14, 2020 by Niroj
• 82,840 points

Related Questions In Angular

0 votes
1 answer

How can we go back to previous page after having some error on request made through current page ?

$route is used for deep-linking URLs to controllers ...READ MORE

answered Feb 11, 2020 in Angular by Niroj
• 82,840 points
1,247 views
0 votes
1 answer

How can we specify no route path in UI-Router?

hey @kartik, In order to route to any ...READ MORE

answered Feb 11, 2020 in Angular by anonymous
• 82,840 points
1,238 views
0 votes
1 answer

How can I strip HTML tags from a string in ASP.NET?

Hello @Kartik, If it is just stripping all HTML tags ...READ MORE

answered Jul 23, 2020 in Angular by Niroj
• 82,840 points
1,793 views
0 votes
1 answer

How to get current value of RxJS Subject or Observable?

Hello @kartik, A Subject or Observable doesn't have a current value. When ...READ MORE

answered Sep 8, 2020 in Angular by Niroj
• 82,840 points
17,479 views
0 votes
1 answer

How can I remove a port from url for node app using nginx

If you run your node server on ...READ MORE

answered Apr 10, 2018 in DevOps on Cloud by ajs3033
• 7,300 points
4,025 views
0 votes
1 answer

Docker : multiples linked containers for each customers

Using Docker (specifically Docker Compose) linking containers ...READ MORE

answered Jul 11, 2018 in Docker by Kalgi
• 2,680 points
594 views
0 votes
4 answers

ReactJS vs Angular Comparison: Which is better?

Parameters React Angular Type React is a JavaScript library, and it ...READ MORE

answered Jan 7, 2021 in Events & Trending Topics by Focusteck
• 140 points
1,727 views
+4 votes
9 answers

***IMPORTANT*** AngularJS Interview Questions.

Yes, I agree with Omkar AngularJs is ...READ MORE

answered Mar 17, 2019 in Career Counselling by Sharad
• 180 points
3,612 views
0 votes
1 answer

How can we redirect to an existing route using ngRoute?

Routing is just another way of fixing some content ...READ MORE

answered Feb 6, 2020 in Angular by Niroj
• 82,840 points
3,711 views
0 votes
1 answer

How can we reload a page after requesting the same get parameter using AngularJS?

hey kartik, The reason for this is that ...READ MORE

answered Feb 10, 2020 in Angular by Niroj
• 82,840 points
12,635 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP