8

I want something like this:

if ($state.get("^")) $state.go("^"); else $location.path('/');

But it apparently won't work (it always goes with $state.go even when there's no parent state). How to correctly do a check if an particular state exists?

1 Answer 1

9

you could use $state.href which will return null if the state does not exist. See http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! So this should work as expected: if ($state.href("^")) $state.go("^"); else $location.path('/');?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.