0

如果我手动触发状态更改(使用 $state.go(toState, toParams)),为什么在我的简单示例中,Angular UI 路由器在 url 中编码斜杠。

$rootScope.$on("$stateChangeStart", function (event, toState, toParams, fromState, fromParams, error) {
            console.log("stateChangeStart");
            $rootScope.loading = true;          
            if(!isLoggedIn) {
                event.preventDefault();
                Api.get().then(function(response){
                    isLoggedIn = response;
                    $state.go(toState, toParams);
                });
            }
        });

这是完整的示例。 http://plnkr.co/1mSXJbN1PMrFiG72oa9m

例如 url 像:/template1 被编码为 %252Ftemplate1。否则状态也被编码。

这真的很奇怪,我怎么能禁用它?

在 $stateChangeStart 事件中,我模拟服务器端用户身份验证。这个问题的另一部分是我如何在这个具体示例中将 url /template1 与 /template1/ 相同?

PS 我关闭了 html5 模式,因为它需要一个正确配置的服务器(用于测试(错误?)在这个例子中需要 html5 模式)。

肿瘤坏死因子

4

0 回答 0