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

      1. <legend id='Pef2r'><style id='Pef2r'><dir id='Pef2r'><q id='Pef2r'></q></dir></style></legend>
          <bdo id='Pef2r'></bdo><ul id='Pef2r'></ul>
      2. <tfoot id='Pef2r'></tfoot>

        Angular UI路由器:具有相同URL的不同状态?

        Angular UI Router: Different states with same URL?(Angular UI路由器:具有相同URL的不同状态?)

          <bdo id='5op5B'></bdo><ul id='5op5B'></ul>

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

            1. <legend id='5op5B'><style id='5op5B'><dir id='5op5B'><q id='5op5B'></q></dir></style></legend><tfoot id='5op5B'></tfoot>

              <small id='5op5B'></small><noframes id='5op5B'>

                <tbody id='5op5B'></tbody>

                • 本文介绍了Angular UI路由器:具有相同URL的不同状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的应用的登陆页面有两种状态:home-publichome-logged-in.现在我想在同一个 URL 上显示两种状态,但让控制器和模板依赖于用户会话(用户是否登录?).

                  The landing page of my app has two states: home-public, home-logged-in. Now I want to show both states on the same URL, but let the controller and template depend on the user session (is the user logged in or not?).

                  有没有办法做到这一点?

                  Is there a way to achieve this?

                  推荐答案

                  你可以有一个基本状态来控制要加载的状态,你可以简单地让声明该基本状态的子状态没有 url:

                  You could have a base state that controls which state to load, and you could simply have the child stated of that base state not have urls:

                  .state('home', {
                    url: "/home",
                    templateUrl: "....",
                    controller: function($scope,$state,authSvc) {
                       if(authSvc.userIsLoggedIn()){
                            $state.go('home.loggedin')
                       }else{
                            $state.go('home.public')
                       }
                    }
                  })
                  
                  
                  .state('home.public', {
                    url: "",
                    templateUrl: "....",
                    controller: function($scope) {
                       ...........
                    }
                  })
                  
                  .state('home.loggedin', {
                    url: "",
                    templateUrl: "....",
                    controller: function($scope) {
                       ...........
                    }
                  })
                  

                  现在在你的基本状态(home)的控制器中,你可以检查用户是否登录,并使用 $state.go() 加载适当的状态.

                  Now in the controller of your base state (home) you can check if the user is logged in or not, and use $state.go() to load an appropriate state.

                  编辑

                  正如所承诺的,一个有效的小程序.

                  这篇关于Angular UI路由器:具有相同URL的不同状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  在开发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 在一年的第一天返回前一年)
                  <legend id='KkZkV'><style id='KkZkV'><dir id='KkZkV'><q id='KkZkV'></q></dir></style></legend>
                    <tbody id='KkZkV'></tbody>
                    <bdo id='KkZkV'></bdo><ul id='KkZkV'></ul>
                    <i id='KkZkV'><tr id='KkZkV'><dt id='KkZkV'><q id='KkZkV'><span id='KkZkV'><b id='KkZkV'><form id='KkZkV'><ins id='KkZkV'></ins><ul id='KkZkV'></ul><sub id='KkZkV'></sub></form><legend id='KkZkV'></legend><bdo id='KkZkV'><pre id='KkZkV'><center id='KkZkV'></center></pre></bdo></b><th id='KkZkV'></th></span></q></dt></tr></i><div id='KkZkV'><tfoot id='KkZkV'></tfoot><dl id='KkZkV'><fieldset id='KkZkV'></fieldset></dl></div>
                    <tfoot id='KkZkV'></tfoot>

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