gaurav
gaurav

Reputation: 127

How to show empty message in datatable, If no data found in angularjs

I am using this code

<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>

So, how to show empty message in datatable, If no data found in angularjs.

Upvotes: 2

Views: 1152

Answers (2)

jcubic
jcubic

Reputation: 66480

You can use ng-hide and check it array is not empty

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

Upvotes: 2

Sajal
Sajal

Reputation: 4401

ng-if to check for length of users:

<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>

Upvotes: 2

Related Questions