这是我的控制者:
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"
答案 0 :(得分:2)
将其设置为$scope
var:
$scope.cookieSet = $cookies.user_id;
视图中无法访问常规var
变量。