2016-12-01 106 views
2

我,我用NG-隱藏和NG-秀展現一個不同的列時vm.allRecords設置爲true嘗試:如何隱藏ng-table列?

<table ng-table="vm.tableParams" ng-hide="vm.noRecords || vm.DashboardService.loading"> 
    <tr ng-repeat="record in $data"> 
     <td title="'Title'" sortable="'title'" class="title"> 
      <a ng-href="{{vm.baseUrl}}#entity/displayEntity?entityId={{record.entityId}}" target="_blank"> 
       {{record.title}} 
      </a> 
     </td> 
     <td title="'Date Created'" sortable="'createdDate'" class="date">{{record.createdDate}}</td> 
     <td title="'Last Modified'" sortable="'lastModified'" class="date">{{record.lastModified}}</td> 
     <td title="'Notebook Descriptor'" sortable="'notebookDescription[0]'" class="description"> 
      <ul> 
       <li ng-repeat="description in record.notebookDescription">{{description}}</li> 
      </ul> 
     </td> 
     <td title="'Witness'" sortable="'witnesses[0].display'" class="witness" ng-hide="vm.allRecords"> 
      <ul> 
       <li ng-repeat="witness in record.witnesses">{{witness.display}}</li> 
      </ul> 
     </td> 
     <td title="'Due Date'" sortable="'dueDate'" class="date" ng-hide="vm.allRecords">{{record.dueDate}}</td> 
     <td title="'Status'" sortable="'status'" class="status" ng-show="vm.allRecords">{{record.status}}</td> 
    </tr> 
</table> 

但頭中的細胞不隱藏。我也嘗試使用自定義th使用此:

<tr> 
    <th>Title</th> 
    <th>Date Created</th> 
    <th>Last Modified</th> 
    <th>Notebook Descriptor</th> 
    <th ng-hide="vm.allRecords">Witness</th> 
    <th ng-hide="vm.allRecords">Due Date</th> 
    <th ng-show="vm.allRecords">Status</th> 
</tr> 

它的工作,但我沒有排序。我怎樣才能隱藏列和排序?

+1

把jsfiddle放在一起。我認爲你做的是相反的,這就是爲什麼它不工作 – yBrodsky

+1

@yBrodsky這裏是小提琴https://jsfiddle.net/39wcrt02/ – jcubic

回答

2

我已經將ng-show/ng-hide更改爲ng-if並且它可以工作。

+0

要完成答案,符合問題的最期望的選項將是ng-如果由於它專門隱藏了列,而ng-hide或ng-show不隱藏