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

Viewed 19211

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?

4 Answers

You should listen to the $locationChangeSuccess event.

There you can use $location.path() or window.location.hash depending on your needs.

Related