gpt4 book ai didi

javascript - angular-ui/ui-router $stateChangeError 从不为不存在的状态触发

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:00:49 25 4
gpt4 key购买 nike

我的问题是 ui-router $stateChangeError 不是由“404”无效状态触发的。

我确定我的 $stateChangeSucess 正确触发:

$rootScope.$on('$stateChangeSuccess', 
function(event, toState, toParams, fromState, fromParams)

当我故意使状态无效时:

 <ui-view>
<a ui-sref="foo" style="cursor: pointer;">Foo is not a state</a>
</ui-view>

$stateChangeError 事件没有被触发,我知道我有正确的签名

angular
.module('blocks.router')
.run(['$rootScope', function($rootScope) {
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
console.log('$stateChangeError fired!');
});
}]);

我将我的函数添加到 $stateChangeError,同时我添加了我的工作 $stateChangeSuccess

对我可能做错的地方有什么建议吗?

最佳答案

Angular-ui-router 有 $stateNotFound对于这种情况

关于javascript - angular-ui/ui-router $stateChangeError 从不为不存在的状态触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39069378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com