简体   繁体   English

angularjs ui-if状态变量设置值异步

[英]angularjs ui-if state variable setting value async

I would like to restrict the side bar until user login completed 我想限制边栏,直到用户登录完成

The side bar is outside the ui-view section 侧栏位于ui视图部分之外

I am assuming authenticated as a state variable 我假设已authenticated为状态变量

<div ng-controller="MyController" ui-prevent-touchmove-defaults>
    <section style="height: 100%" layout="row" flex="">
        <div ui-if="authenticated" ng-include="'pages/sidebar.html'"></div>
        <md-content id="container" style="overflow:hidden;height: 100%;padding: 0 0 0 0" ui-view flex=""></md-content>
    </section>
</div>

In JavaScript code I have an initial value 在JavaScript代码中,我有一个初始值

SharedState.initialize($rootScope, "authenticated", false);

But when I call this method after login 但是当我登录后调用此方法时

SharedState.initialize($rootScope, "authenticated", true);

The UI is not appearing, how to achieve this, is there a trigger method to do re-render? UI没有出现,如何实现,是否有触发方法可以重新渲染?

Initialize method you can call one time at controller level, but trigger the ui state you can use turnOn Method 您可以在控制器级别调用一次Initialize方法,但是可以使用turnOn方法触发ui状态

SharedState.turnOn("authenticated");

Refer the Mobile Angular UI Documentation - SharedState:turnOn 请参阅Mobile Angular UI文档-SharedState:turnOn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM