<bdo id='pBvXA'></bdo><ul id='pBvXA'></ul>

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

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

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

      2. Angular JS ui-router如何从父母重定向到子状态?

        Angular JS ui-router how to redirect to a child state from a parent?(Angular JS ui-router如何从父母重定向到子状态?)
            <legend id='Vak1r'><style id='Vak1r'><dir id='Vak1r'><q id='Vak1r'></q></dir></style></legend>
              <tbody id='Vak1r'></tbody>

            1. <tfoot id='Vak1r'></tfoot>
                <bdo id='Vak1r'></bdo><ul id='Vak1r'></ul>

                • <small id='Vak1r'></small><noframes id='Vak1r'>

                • <i id='Vak1r'><tr id='Vak1r'><dt id='Vak1r'><q id='Vak1r'><span id='Vak1r'><b id='Vak1r'><form id='Vak1r'><ins id='Vak1r'></ins><ul id='Vak1r'></ul><sub id='Vak1r'></sub></form><legend id='Vak1r'></legend><bdo id='Vak1r'><pre id='Vak1r'><center id='Vak1r'></center></pre></bdo></b><th id='Vak1r'></th></span></q></dt></tr></i><div id='Vak1r'><tfoot id='Vak1r'></tfoot><dl id='Vak1r'><fieldset id='Vak1r'></fieldset></dl></div>
                • 本文介绍了Angular JS ui-router如何从父母重定向到子状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  When using onEnter to redirect to a state, if the new state is a child of the current state, an infinite loop occurs.

                  Example:

                  $stateProvider
                    .state 'inventory',
                      url: '/inventory'
                      templateUrl: 'views/inventory.html'
                      controller: 'InventoryCtrl'
                      onEnter: () ->
                        $state.go 'inventory.low'
                    .state 'inventory.low',
                      url: '/low'
                      templateUrl: 'views/inventory-table.html'
                      controller: 'LowInventoryCtrl'
                  

                  When:

                  $state.go 'inventory.low'
                  

                  Is called, the state inventory is re-initialized, causing it to be called again = infinite loop.

                  However, if the redirect state is:

                  $state.go 'otherStateThatIsNotAChild'
                  

                  This issue does not occur. I assume that the parent state is being re-initialized, but why?

                  1. Why is the parent state being reinitialized when .go is called on a child state?
                  2. How then, would you handle redirecting to a child state?

                  解决方案

                  1) Why is the parent state being reinitialized when .go is called on a child state?

                  While a transition is in process, any $state.go/transitionTo will cause the currently in process transition to be Superseded. An in-process transition that is superseded is cancelled immediately. Since your original transition to inventory is not completed by the time all the states' onEnters are called, the original transition is cancelled and a new transition to inventory.low is started from the previously active state.

                  See ui-router src https://github.com/angular-ui/ui-router/blob/master/src/state.js#L897 ...

                  2) How then, would you handle redirecting to a child state?

                  You could...

                  • Wrap $state.go in a $timeout() to allow the original transition to complete before redirecting.
                  • Call $state.go from your controller instead. UI-router invokes the controller from the ui-view directive AFTER the transition is completed.

                  In any case, be very sure you want your app to redirect like this. If a user navigated directly to any other child state of inventory (such as inventory.high), the redirect will still occur, forcing them to inventory.low which would not be what they intended.

                  这篇关于Angular JS ui-router如何从父母重定向到子状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  在开发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 在一年的第一天返回前一年)

                    <small id='8vV3R'></small><noframes id='8vV3R'>

                          <tbody id='8vV3R'></tbody>

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

                          <tfoot id='8vV3R'></tfoot>

                            <bdo id='8vV3R'></bdo><ul id='8vV3R'></ul>