2015-04-16 22 views
0

我是angularjs中的新蜜蜂,我通过angularjs显示div。但是,subheaddiv(index)函数中的值会更改,但不会反映在html中。无法显示div来自ng显示

的Html剪断: -

<div ng-repeat="details in feeHeadDetails"> 
    <h4 class="panel-title"> 
     {{details.name}} 
      <div ng-show="{{details.add}}"> 
        <div ng-click="**subheaddiv($index)**" class="pull-right"> 
        <div class="col-xs-12"> 
         <button class="btn btn-primary"><i class="fa fa-plus"></i>Add Sub Head</button> 
        </div> 
       </div> 
       <div ng-show="{{details.deletable}}" class="pull-right"> 
       <div class="col-xs-12"> 
        <button headid="{{details.id}}" ng-click="deleteHead($event, $index)" class="btn btn-danger">Delete</button> 
         </div> 
       </div> 
       </div> 
      </h4> 

角脚本:

$scope.subheaddiv = function (index) { 
    $scope.feeHeadDetails[index].add = false; 
    $scope.feeHeadDetails[index].save = true; 
    console.log($scope.feeHeadDetails[index]); 
}; 
+1

您不必应用{{}}使用时NG -show – Himanshu

+0

确实,一只新的蜜蜂。 – Huey

回答

3

尝试删除括号:

ng-show="details.add" 
ng-show="details.deletable" 
+1

是的!这是问题..感谢.. @ demidas,快速响应并节省我的时间。 – vineet

+0

@chotesah,不客气! –

2

Ng Docs

ngShow指令根据 提供给ngShow属性的表达式显示或隐藏给定的HTML元素。

对于NG-显示/ NG隐藏/ NG-如果,您可以使用该模型表达本身,而不是{{}}

<div ng-show="details.add">