achu achu - 4 months ago 47
AngularJS Question

how to hide the table row on ng-click

Using ng-repeat i am repeating the tr, Each row will have the one delete button,
when i click on the delete button that parent tr want to hide, how can it possible using angularjs

<tr ng-repeat="affiliate in affiliateList" ng-hide='num == $index'>
<td>{{affiliate.affName}}</td>
<td>{{affiliate.affUrl}}</td>
<td>{{affiliate.associatedId}}</td>
<td><span class="btn btn-small" ng-click="delete(affiliate.affId); deleteList($index)">Delete</span></td>
</tr>


$scope.num = 0;
$scope.deleteList = function(index){
$scope.num = index;
}

Answer

You can try this code and it doesn't need to write the function.

<tr ng-repeat="affiliate in affiliateList" ng-hide='num == $index'>
      <td>{{affiliate.affName}}</td>
      <td>{{affiliate.affUrl}}</td>
      <td>{{affiliate.associatedId}}</td>
      <td><span class="btn btn-small" ng-click="delete(affiliate.affId); num=$index">Delete</span></td>
</tr>
Comments