[英]ng-show not showing with variable check
This is my controller: 这是我的控制器:
capApp.controller('cookieCtrl', ['$scope','$cookies', function($scope, $cookies) {
var cookieSet = $cookies.user_id;
alert('coolkie is ' + cookieSet); // this is fine and shows the value
}]);
And the nav I want to show: 我想展示的导航是:
<div id="siteNav2" ng-controller="cookieCtrl">
<nav class="navbar navbar-inverse navbar-fixed-top" ng-show="cookieSet">
... all nav here ...
</nav>
</div>
But it shows, then disappears... 但它显示,然后消失...
I also tried, but same result: 我也尝试过,但结果相同:
ng-show="cookieSet != null"
Set it to a $scope
var: 将其设置为
$scope
var:
$scope.cookieSet = $cookies.user_id;
Regular var
variables are not accessible in the view. 在视图中无法访问常规
var
变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.