2016-06-29 50 views
0

我正在填充Angular中的表格,但我希望它能夠顯示錯誤消息是我的數組是空的,我可以找到解決方案,當它與列表,但我不知道如何將其轉換爲表格。空表上的消息Angular

任何幫助,將不勝感激!

代碼:

<table class="datatable"> 
    <tr> 
    <th><input ng-model="allSelected" ng-change="selectAll()" type="checkbox"></th> 
    <th>Image</th> 
    <th> 
     <div class="headerButtons"><a ng-click="order('name')">Name<i class="material-icons md-18">swap_vert</i></a></div> 
    </th> 
    <th> 
     <div class="headerButtons"><a ng-click="order('type')">Type<i class="material-icons md-18">swap_vert</i></a></div> 
    </th> 
     <th> 
     <div class="headerButtons"><a ng-click="order('type')">Dimensions<i class="material-icons md-18">swap_vert</i></a></div> 
    </th> 
     <th> 
     <div class="headerButtons"><a ng-click="order('type')">Media Linkage<i class="material-icons md-18">swap_vert</i></a></div> 
    </th> 

    </tr> 

    <tr ng-repeat="file in (filteredImageData = (imageData | filter:search | filter:myFilter))"> 
    <context-menu ng-init="file.hidden = true" owner="file" menu-data="contextMenuFields"></context-menu> 
    <td><input ng-model="file.selected" type="checkbox"></td> 
    <td><div ng-if="file.type == 'image'"> 
     <a ng-click="openCarousel(file,$index)"><img ng-src="http://XXXX/{{file.url}}" width="65" height="65" get-image-resolution="file.size"></div> 
     <div ng-if="file.type == 'video'"> 
     <a ng-click="openCarousel(file,$index)"><i class ="material-icons md-24">videocam</i ></div> 
     <div ng-if="file.type == 'audio'"> 
     <a ng-click="openCarousel(file,$index)"><i class="material-icons md-24">volume_up</i></div> 
     </td> 
     <td> 
     {{file.name}} 
     <div class="dropdown"><a ng-click="contextMenuFields.show($event,file)"><i class="material-icons">more_horiz</i></div></td>   

    <td>{{file.type}}<i class="greyedOut"> {{file.name | getextension}}</i></td> 
    <td>{{file.size.x}}<i class="greyedOut"> x</i> {{file.size.y}}<i class="greyedOut"> px</i></td> 
    <!--<td>blurp{{getRes(http://XXXX/{{file.url}})}}</td>--> 
    <td>{{file.folder}}</td> 

    <!--<td>{{file.type}}{{getExtension(file.name)}}</td>--> 

    </tr> 

</table> 

回答

1

替換代碼利用ng-if。以下是您可以使用的示例代碼:

<tr ng-if="(!filteredImageData || filteredImageData.length < 1)"> <td colspan="6">There are no records to show</td> </tr> <tr ng-if="filteredImageData" ng-repeat="file in (filteredImageData = (imageData | filter:search | filter:myFilter))">

+0

乾杯!它仍然是越野車,當我試圖做到以下幾點:

任何想法爲什麼? –

+0

請嘗試下面的代碼: '

' 希望這可以解決您的問題... :) – seekers01