我是angularjs中的新蜜蜂,我通过angularjs显示div的问题。但是,在subheaddiv(index)函数中更改了值,但未在html中反映。
Html Snipped: -
<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>
Angular Script:
$scope.subheaddiv = function (index) {
$scope.feeHeadDetails[index].add = false;
$scope.feeHeadDetails[index].save = true;
console.log($scope.feeHeadDetails[index]);
};
答案 0 :(得分:3)
尝试删除大括号:
ng-show="details.add"
ng-show="details.deletable"
答案 1 :(得分:2)
来自 Ng Docs
ngShow指令显示或隐藏基于的给定HTML元素 表达式提供给ngShow属性。
对于ng-show / ng-hide / ng-if,您可以使用模型表达式本身而不是{{}}
<div ng-show="details.add">