我無法在$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 - 做這樣的事情最有角度的方式是什麼?
'ng-hide =「logged」'? – 2014-12-03 11:57:13
@NaeemShaikh,謝謝你的訣竅:) – sameera207 2014-12-03 21:13:09