我想要这样的东西:if ($state.get("^")) $state.go("^"); else $location.path('/');
但它显然不起作用(即使没有父状态,它也总是与 $state.go
一起使用)。如何正确检查特定状态是否存在?
最佳答案
您可以使用 $state.href 如果状态不存在,它将返回 null。见 http://angular-ui.github.io/ui-router/site/#/api/ui.router.state .$状态
关于angularjs - UI 路由器 - 检查状态是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38227022/