Trevor Trevor - 2 months ago 14
AngularJS Question

How can I get the full url of the current ui-router state?

I'm using ui-router for AngularJS; I'm handling the

'$stateChangeSuccess'
event, and trying to get the full path (after '#') for the current state.
$location.hash()
returns an empty string and
$state.url
returns only the portion of the path that applies to the nested state.

My full path
#/a/b


$state.url == "/b"
$locadtion.hash() == ""


How can I get
#/a/b
or
/a/b
?

Ben Ben
Answer

You can always use:

window.location 

or:

window.location.hash 

(if that's what you want).