UI Router - Check if a state exists
<p>I want something like this:    </p>

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

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