<small id='6IgG6'></small><noframes id='6IgG6'>

    • <bdo id='6IgG6'></bdo><ul id='6IgG6'></ul>

  1. <i id='6IgG6'><tr id='6IgG6'><dt id='6IgG6'><q id='6IgG6'><span id='6IgG6'><b id='6IgG6'><form id='6IgG6'><ins id='6IgG6'></ins><ul id='6IgG6'></ul><sub id='6IgG6'></sub></form><legend id='6IgG6'></legend><bdo id='6IgG6'><pre id='6IgG6'><center id='6IgG6'></center></pre></bdo></b><th id='6IgG6'></th></span></q></dt></tr></i><div id='6IgG6'><tfoot id='6IgG6'></tfoot><dl id='6IgG6'><fieldset id='6IgG6'></fieldset></dl></div>
    1. <legend id='6IgG6'><style id='6IgG6'><dir id='6IgG6'><q id='6IgG6'></q></dir></style></legend>
      <tfoot id='6IgG6'></tfoot>

      错误:Angular Ui 路由器状态更改时超出了最大调用堆栈大小

      Error: Maximum call stack size exceeded on Angular Ui Router State Change(错误:Angular Ui 路由器状态更改时超出了最大调用堆栈大小)

      <small id='92iGb'></small><noframes id='92iGb'>

    2. <legend id='92iGb'><style id='92iGb'><dir id='92iGb'><q id='92iGb'></q></dir></style></legend>

              <bdo id='92iGb'></bdo><ul id='92iGb'></ul>
            • <tfoot id='92iGb'></tfoot>
              <i id='92iGb'><tr id='92iGb'><dt id='92iGb'><q id='92iGb'><span id='92iGb'><b id='92iGb'><form id='92iGb'><ins id='92iGb'></ins><ul id='92iGb'></ul><sub id='92iGb'></sub></form><legend id='92iGb'></legend><bdo id='92iGb'><pre id='92iGb'><center id='92iGb'></center></pre></bdo></b><th id='92iGb'></th></span></q></dt></tr></i><div id='92iGb'><tfoot id='92iGb'></tfoot><dl id='92iGb'><fieldset id='92iGb'></fieldset></dl></div>
                  <tbody id='92iGb'></tbody>

                本文介绍了错误:Angular Ui 路由器状态更改时超出了最大调用堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                基本上我要做的是根据用户身份验证状态更改状态.

                Basically what I'm trying to do is change the state depending on user authentication status.

                当我在没有 $rootScope 的情况下执行 $state.go(); 时,我可以在没有错误的情况下重定向到页面,但是当我使用

                When I do $state.go(); without $rootScope, I can redirect to the page without the error but when I do with

                $rootScope.$on('$stateChangeStart', function (event) {$state.go();event.preventDefault()})

                以下是控制器代码:

                DiaryDashboard.controller('AppController', 
                  ['$scope', '$rootScope', '$localStorage', '$http', '$state'
                  , function ($scope, $rootScope, $localStorage, $http, $state) {
                
                  $rootScope.$on('$stateChangeStart', function (event, toState) {
                
                    if ($localStorage.userdetails &&
                        $localStorage.userdetails.isAuthenticated == true) {
                
                        //Check for Authentication state
                        //If not redirect to the state in the else clause
                        //Populate the $rootScope with user details
                        $rootScope.userdetails = $localStorage.userdetails;
                
                        //Switch to the parent state
                        $state.go();
                        event.preventDefault();
                
                    } else {
                
                        //If User not authenticated
                        //GO to the Authentication State
                        $state.go('auth');
                        event.preventDefault();
                
                    }
                  })
                
                }]);
                

                推荐答案

                这里最重要的是要明白这一点:

                The most important thing here is to understand this:

                如果不需要,请不要重定向.换句话说,如果用户已经被重定向到预期状态 - 我们应该离开......有 一个工作plunker 具有类似的解决方案.

                Do not redirect if not needed. Other words, if user is already redirected to intended state - we should leave... There is a working plunker with similar solution.

                查看此问答答:

                调整后的代码:

                $rootScope.$on('$stateChangeStart', function (event, toState) {
                
                    var isNavigatingToAuth = toState.name === "Auth";
                
                    if(isNavigatingToAuth){
                
                       return; // no need to redirect 
                    }
                
                    if ($localStorage.userdetails &&
                        $localStorage.userdetails.isAuthenticated == true)
                    ...
                

                这篇关于错误:Angular Ui 路由器状态更改时超出了最大调用堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                Ordinals in words javascript(javascript中的序数)
                getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                    <tbody id='CgpBN'></tbody>
                  • <i id='CgpBN'><tr id='CgpBN'><dt id='CgpBN'><q id='CgpBN'><span id='CgpBN'><b id='CgpBN'><form id='CgpBN'><ins id='CgpBN'></ins><ul id='CgpBN'></ul><sub id='CgpBN'></sub></form><legend id='CgpBN'></legend><bdo id='CgpBN'><pre id='CgpBN'><center id='CgpBN'></center></pre></bdo></b><th id='CgpBN'></th></span></q></dt></tr></i><div id='CgpBN'><tfoot id='CgpBN'></tfoot><dl id='CgpBN'><fieldset id='CgpBN'></fieldset></dl></div>
                    <tfoot id='CgpBN'></tfoot>

                    <small id='CgpBN'></small><noframes id='CgpBN'>

                    • <bdo id='CgpBN'></bdo><ul id='CgpBN'></ul>

                        1. <legend id='CgpBN'><style id='CgpBN'><dir id='CgpBN'><q id='CgpBN'></q></dir></style></legend>