2013-08-04 24 views
2

我有以下幾點:有什麼方法可以啓用/禁用在Angular中的表中顯示列?

<select 
    data-ng-model="option.selectedValue" 
    data-ng-options="item.id as item.name for item in option.selects"> 
</select> 

<table> 
    <thead> 
     <tr> 
      <th>Id</th> 
      <th>City</th> 
      <th>Street</th> 
     </tr> 
    </thead> 
    <tbody class="grid"> 
     <tr data-ng-repeat="row in grid.data"> 
      <td>{{ row.iD }}</td> 
      <td>{{ row.city }}</td> 
      <td>{{ row.street }}</td> 
     </tr> 
    </tbody> 
</table> 

有沒有辦法爲我改變它,因此街道列變得可見僅當option.selectedValue等於0

+0

你可以這樣: {{row.street}} – AlwaysALearner

回答

3

試試這個在您的{{row.street}}street

<th ng-show='option.selectedValue == 0'>Street</th> 
... 
<td ng-show='option.selectedValue == 0'>{{row.street}}</td> 

<th ng-hide="option.selectedValue != 0">Street</th> 
... 
<td ng-hide='option.selectedValue != 0'>{{row.street}}</td> 

這是一樣的;)

1

使用ng-show。您需要隱藏header columncontent column

<th ng-show="option.selectedValue == 0">Street</th> 
<td ng-show="option.selectedValue == 0">{{ row.street }}</td> 

Demo

相關問題