空表Angular上的消息

时间:2016-06-29 12:36:25

标签: angularjs html-table message

我在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 个答案:

答案 0 :(得分: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))">