在一个AngularJS(1.2.7)项目,使用的UI路由器(0.2.8),我想申请的当前状态为一类到UI视图元素,因为这可以让我申请特定状态的动画,例如:做一个过渡,从登录要开始做转移B从开始去设置。
In a AngularJS (1.2.7) project, using UI Router (0.2.8), I want to apply the current state as a class to the ui-view element, because that would allow me to apply animations for specific states, e.g. do transition A going from login to start and do transition B going from start to settings.
目前,我对$ rootScope的$状态对象(如提到这里,这让我用纳克级=$ state.current.name在身体上添加一个基于状态的类。但是,如果我补充一点,到UI视图元素,如:
At the moment I have the $state object on the $rootScope (as mentioned here, which allows me to add a state-based class on the body using ng-class="$state.current.name". However, if I add that to the ui-view element, e.g.
<div ui-view ng-class="$state.current.name"></div>
那么类是一步背后的实际状态。因此,从登陆到开始走出去的时候,班级将登录,而不是启动。
Then the class is one step behind the actual state. So when going from "login" to "start", the class will be "login" instead of "start".
我觉得这是一个错误,你可以阅读更多关于这里的问题:
I think this is a bug, you can read more about the issue here:
https://github.com/angular-ui/ui-router/issues/866
直到它是固定的,我建议这样的解决方法:
Until it is fixed I suggest such a workaround:
<div ng-class="$state.current.name"><div ui-view></div></div>