2
我有一个基于身份验证的登录页面,我显示/隐藏div。 Div使用$ scope.userdetails来显示或隐藏。ng-show没有正确更新
<table class="txt_logged" ng-controller="mainCtrl" ng-show="{{userdetails}}">
下面是控制器手表方法
.controller('mainCtrl',['$scope','SharedService',function($scope,SharedService)
{
$scope.userdetails=SharedService.getUserDetails();
$scope.$watch(function(){ return SharedService.getUserDetails()}, function(newValue, oldValue)
{
if (newValue && newValue !== oldValue)
{
var t= SharedService.getUserDetails();
if(t.toString()=="true")
{
$scope.userdetails =true;
}
else
{
$scope.userdetails =false;
}
}
});
}]);
为什么NG-显示没有更新
感谢它的工作。你可以解释为什么{{userdetails}}不起作用。 – bharath 2014-09-01 07:27:41