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 in Angular by Ava
• 120 points
40 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 by Niroj
• 76,940 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 in Angular by Niroj
• 76,940 points
101 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 in Angular by anonymous
• 76,940 points
99 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 in Angular by Niroj
• 76,940 points
90 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 in Angular by Niroj
• 76,940 points
432 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,280 points
1,644 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,620 points
76 views
0 votes
3 answers

ReactJS vs Angular Comparison: Which is better?

One picture, many facts How can you compare ...READ MORE

answered Aug 10, 2018 in Events & Trending Topics by slayer
• 29,300 points
206 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
952 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 in Angular by Niroj
• 76,940 points
442 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 in Angular by Niroj
• 76,940 points
5,273 views