【问题标题】:How to show empty message in datatable, If no data found in angularjs如何在数据表中显示空消息,如果在 angularjs 中找不到数据
【发布时间】:2016-05-13 09:22:52
【问题描述】:

我正在使用此代码

<table class="table table-striped b-t b-b patient-search-table"
ui-jp="dataTable" ui-option='{"emptyTable": "My Custom Message On
Empty Table"}'>
<tr><th>Name</th></tr>
<tr ng-repeat="user in users">
<td class="text-capitalize">{{user.name}}</td>
</tr>

那么,如果在 angularjs 中找不到数据,如何在数据表中显示空消息。

【问题讨论】:

  • 试试&lt;div ng-hide="users.length"&gt;No Data Found&lt;/div&gt;
  • 请具体说明我应该把你建议的代码行放在哪里?
  • 可以放在桌子后面。
  • @jcubic 感谢它在没有ui-option 的情况下工作。非常感谢
  • @jcubic :请您将您的评论作为 ans,以便此问题已接受 ans。否则人们会来ans。

标签: javascript angularjs datatable


【解决方案1】:

您可以使用 ng-hide 并检查它的数组是否为空

<div ng-hide="users.length">No Data Found</div>

【讨论】:

    【解决方案2】:

    ng-if 检查用户长度:

    <table class="table table-striped b-t b-b patient-search-table"
    ui-jp="dataTable" ui-option='{"emptyTable": "My Custom Message On
    Empty Table"}' ng-if="users.length > 0">
    <tr><th>Name</th></tr>
    <tr ng-repeat="user in users" >
    <td class="text-capitalize">{{user.name}}</td>
    </tr>
    <div ng-if="users.length == 0">My Custom Message On Empty table</div>
    

    【讨论】:

    • 您建议的 ng-if 和我的 ui-option 都可以使用,或者只是您的。谢谢。
    • &lt;div ng-hide="users.length"&gt;No Data Found&lt;/div&gt; 它对我有用 谢谢
    猜你喜欢
    • 1970-01-01
    • 2012-12-31
    • 2019-08-06
    • 2010-12-31
    • 1970-01-01
    • 2020-08-10
    • 2021-01-21
    相关资源
    最近更新 更多