UI路由器有条件的用户界面有何看法? [英] UI Router conditional ui views?

查看:101
本文介绍了UI路由器有条件的用户界面有何看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不出一个合理的方式,不觉得自己像一个黑客,来解决这个相当琐碎的问题。

I can't figure out a reasonable way, which doesn't feel like a hack, to solve this rather trivial problem.

我想一个客人看到启动页面时,他们访问索引的网站和登录的用户看到他们的个人资料,具有它自己的模板,并控制每个页面。 理想的情况下,将有一个网址两种状态,并不知我将能够自动地改变活跃的一个取决于洛状态。这两种观点都会有自己的嵌套意见,NG-包括不能使用(我假设)。

I want a guest to see a splash page when they access the index of the website and a logged in user to see their profile, with each page having it's own template and controller. Ideally, there would be two states for one url, and somehow I would be able to automatically alter the active one depending on the loggin status. Both of these views will have their own nested views so ng-include cannot be used (I assume).

我是很新的角度和用户界面的路由器,想我可能俯瞰一个简单的解决问题的办法。

I'm quite new to angular and ui router and think I might be overlooking an easy solution to the problem.

难道是与命名视图和NG-秀做了什么?

Could it be done with named views and ng-show?

推荐答案

如果你使用路由器的用户界面,只需要建立三种状态:根状态下,与/地址,然后用任何URL两次直接后裔状态。在的OnEnter 根的状态,你相应地检测到用户并过渡到正确的子状态的状态。这使保持两个孩子的状态相同的URL的外观,但可以让你有与单独配置独立的国家。

If you're using UI Router, just create three states: the root state, with the '/' URL, and two direct descendant states with no URLs. In the onEnter of the root state, you detect the state of the user and transition to the correct child state accordingly. This gives the appearance of keeping the same URL for both child states, but allows you to have to separate states with separate configurations.

这篇关于UI路由器有条件的用户界面有何看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆