How to find out what the current route is

117 views
Skip to first unread message

Manfred Steyer

unread,
Dec 29, 2015, 6:27:06 PM12/29/15
to AngularJS
Hi,

currently, I use the Location-Service to find out, what the current route is:

isActive(path): boolean {
    if (path == '') return this.location.path() == '';  
    return (this.location.path().startsWith(path));
}

But I'm looking for a better way of doing so, cause in this case, I'm working with the url (that might change during development) and not with the internal route-name.

Is there a way to get the name of the current route?

Wishes,
Manfred

Günter Zöchbauer

unread,
Dec 30, 2015, 6:33:10 AM12/30/15
to AngularJS

Manfred Steyer

unread,
Dec 30, 2015, 5:51:34 PM12/30/15
to AngularJS
Hi Günter,

thx for your answer. Unfortunatelly I can not see how to find out the internal name of the current route with this. It seems to be possible, to use the Router-Object to find out, whether the current route matches an exact RouteInstruction (that includes the full route-name as well as routing-parameter).

What I need is the current route-name to find out whether it (partially) matches a given name.

Do you have a solution for this?

Wishes,
Manfred

Günter Zöchbauer

unread,
Dec 30, 2015, 6:43:26 PM12/30/15
to AngularJS
No I haven't done much with routing myself yet, I just remembered that there was something similar on SO when I saw your question.

Katie

unread,
Mar 25, 2016, 2:25:35 PM3/25/16
to AngularJS
Hi Manfred! 

I am also interested in this issue, but there seems to be no more information available now than there was in December. Did you ever find a solution?

cheers,

Katie
Reply all
Reply to author
Forward
0 new messages