2016-03-08 71 views
0

我试图绑定服务价值几申报单”NG-显示未与布尔值

<body ng-controller="PageConfigurationController"> 
<label>{{TopLeftPage}}</label><label>{{TopRightPage}}</label> 
<label>{{ButtomRightPage}}</label><label>{{ButtomLeftPage}}</label> 
<div ng-show="{{TopLeftPage}}"><h1>Div1 </h1></div> 
<div ng-show="{{TopRightPage}}"><h1>Div2 </h1></div> 
<div ng-show="{{ButtomRightPage}}"><h1>Div3 </h1></div> 
<div ng-show="{{ButtomLeftPage}}"><h1>Div4 </h1></div> 

的标签显示布尔工作值正常,但在默认情况下所有的div都hidded,无论如果这是真的还是假的。

+0

NG-显示已绑定的角度没有必要的{{}} – Prasad

回答

3
<div ng-show="TopLeftPage"><h1>Div1 </h1></div> 
    <div ng-show="TopRightPage"><h1>Div2 </h1></div> 
    <div ng-show="ButtomRightPage"><h1>Div3 </h1></div> 
    <div ng-show="ButtomLeftPage"><h1>Div4 </h1></div> 

从您的NG-显示和删除花括号JS

$scope.TopLeftPage=true; 
    $scope.TopRightPage=true; 
    $scope.ButtomRightPage=true; 
    $scope.ButtomLeftPage=true; 

//真作秀,假的隐藏

1

您可以直接使用表达NG-显示

<div ng-show="TopLeftPage"><h1>Div1 </h1></div> 
<div ng-show="TopRightPage"><h1>Div2 </h1></div> 
<div ng-show="ButtomRightPage"><h1>Div3 </h1></div> 
<div ng-show="ButtomLeftPage"><h1>Div4 </h1></div> 

,并确保表达式的值应该是真的还是假的布尔不串