单击div内的按钮关闭div

时间:2017-10-09 11:44:02

标签: html angularjs

我想点击按钮

关闭ng-repeat div

HTML

<div ng-repeat="indexVal in vm.flowObject track by $index">
    <div ng-show="listItems.title=='Menu'" class="Margin_Set" id="div2" scroll>
        <button>
            Close div
        </button>
    </div>
</div>

JS

 $scope.listItems = [{
      name: "some name",
      title: "Menu"
  }];

https://jsfiddle.net/uey4xr5L/

2 个答案:

答案 0 :(得分:0)

您可以在点击时添加隐藏属性并将其设置为 true

<div ng-repeat="indexVal in vm.flowObject track by $index">
    <div ng-hide="indexVal.hidden == true" class="Margin_Set" id="div2" scroll>
        <button ng-click="indexVal.hidden = true"> Close div </button>
   </div>
 </div>

答案 1 :(得分:0)

试试这样。

1 = 0.85
2 = 0.65
3 = 0.4
4 = 0.25
var app = angular.module('myApp', []);

app.controller('myCtrl', function($scope){
 $scope.listItems = [{
      name: "some name",
      title: "Menu"
    }];
});