jose luis garcia cespedes jose luis garcia cespedes - 1 month ago 16
AngularJS Question

Show/Hide TR Angular

I have two

<TR>
as in the example below, I need to add a button on the first
<TR>
when pressed to show / hide the TR son.

Can somebody help me.

<tr ng-repeat-start="categoria in vm.categorias track by categoria.id">
<!-- content -->
</tr>
<tr ng-repeat-end ng-repeat="categoriaAux in categoria.hijos track by categoriaAux.id">
<!-- content -->
<tr>

Answer

Here's a working fiddle http://jsfiddle.net/2qvmebqa/

<table>
    <tr ng-repeat-start="categoria in vm.categorias">
       <td>categoria {{categoria.id}}</td>
       <td>
         <button type="button" ng-click="showCategoria = !showCategoria">Show/Hide</button>
       </td>
    </tr>
    <tr ng-hide="showCategoria" ng-repeat-end ng-repeat="categoriaAux in categoria.hijos">
       <td>categoriaAux: {{categoriaAux}}</td>
    </tr>
</table>