2016-07-29 44 views
2

我試圖獲得一個<div>當你按下一個表格中的一行按鈕時,該行就會出現。但<div>出現在所有行中。AngularJS:ng-repeat和ng-if

<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> 

在控制器:

$scope.activateCompany = function (id) { 
    $scope.idcompany = id; 
}; 
+0

ng-if =「company.verified == false」,試試這個 –

+0

我認爲他的問題是第二個ng-if @tom moc –

+0

是的,可能是.. @lban,提供完整的代碼。 –

回答

1

確保你的HTML結構是正確的(ng-ifng-repeat)。

更新HTML到:

<tr ng-repeat="company in companiesList track by $index"> 
    .... 
    <div ng-if="!company.verified"> 
    <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> 
</tr> 

希望這有助於你!

+0

不適用!謝謝......問題在於第二個ng-if –