我在尝试将我的更改反映在$rootScope
. 据我了解(请注意,我对 很陌生angular
),$rootScope
在controllers
. 我要做的是更新一个值$rootScope
并尝试在我的html
页面中读取该值。
问题是即使更改应用到$rootScope
它没有反映在我看来。以下是代码
我有一个div
我想根据值显示/隐藏的
#view
<div ng-hide="{{logged}}">
// this should visible only if the logged is true
</div>
#controller1 I set the rootscope to false
$rootScope.logged = false; // this makes the view hidden
#controller2 I set the rootScope to true
$rootScope.logged = true;
$rootScope.$apply();
但是制作$rootScope.logged = true
并不会使视图可见。我的问题是
1 - 我可能出了什么问题?
2 - 做这种事情最有角度的方式是什么?