Angularjs: ng-repeat and ng-if

1

I have a table that I fill with ng-repeat, in each row I have a button and I want that when I click on it the second ng -if="company.id == idcompany" appears but only in that row and it appears in all. How can I do it?

<tr ng-repeat="company in companiesList">
........
<div ng-if="company.verified == 'false'">
<input type="button" ng-class="classBtnActivar" value="ACTIVAR" ng-click="activateCompany(company.id)">
   <div style="background-color: #d1d1d1; border-radius: 100px;" ng-if="company.id == idcompany">
       <p style="text-align: center">¿Quieres activar todos los comercios de la compañía?</p>
       <div style="text-align: center">
           <input type="button" ng-class="classBtnActivar" value="SI" style="text-align: center">
           <input type="button" ng-class="classBtnActivar" value="NO" style="text-align: center">
       </div>
   </div>
</div>
    
asked by Iban Lopez 29.07.2016 в 11:06
source

1 answer

0

first you have to make a variable $ scope.fila, that in the same method of activateCompany you have to pass the position, then you compare. However, you can try it without passing the id, only the position. I hope it works for you.

<tr ng-repeat="company in companiesList">
........
<div ng-if="!company.verified">
<input type="button" ng-class="classBtnActivar" value="ACTIVAR" ng-click="activateCompany(company.id, $index)">
<div style="background-color: #d1d1d1; border-radius: 100px;" ng-if="company.id == idcompany && $index == fila">
    <p style="text-align: center">¿Quieres activar todos los comercios de la compañía?</p>
   <div style="text-align: center">
       <input type="button" ng-class="classBtnActivar" value="SI" style="text-align: center">
       <input type="button" ng-class="classBtnActivar" value="NO" style="text-align: center">
   </div>
</div>
</div>
</tr>
    
answered by 01.08.2016 / 16:41
source