簡體   English   中英

ng-show不顯示帶有變量檢查

[英]ng-show not showing with variable check

這是我的控制器:

capApp.controller('cookieCtrl', ['$scope','$cookies', function($scope, $cookies) {
  var cookieSet = $cookies.user_id;
  alert('coolkie is ' + cookieSet); // this is fine and shows the value
}]);

我想展示的導航是:

<div id="siteNav2" ng-controller="cookieCtrl">
  <nav class="navbar navbar-inverse navbar-fixed-top" ng-show="cookieSet">
    ... all nav here ...
  </nav>
</div>

但它顯示,然后消失...

我也嘗試過,但結果相同:

ng-show="cookieSet != null"

將其設置為$scope var:

$scope.cookieSet = $cookies.user_id;

在視圖中無法訪問常規var變量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM