消息空 table Angular
Message on empty table Angular
我正在 Angular 中填写 table 但我希望它能够显示错误消息是我的数组是空的,我可以在列表中找到解决方案但是我不知道如何将其转换为 table.
如有任何帮助,我们将不胜感激!
代码:
<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>
替换代码以使用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))">
我正在 Angular 中填写 table 但我希望它能够显示错误消息是我的数组是空的,我可以在列表中找到解决方案但是我不知道如何将其转换为 table.
如有任何帮助,我们将不胜感激!
代码:
<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>
替换代码以使用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))">