繁体   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