2

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.

5
  • Try <div ng-hide="users.length">No Data Found</div> Commented May 13, 2016 at 9:26
  • Please specify, exactly where should I put your suggested code line ? Commented May 13, 2016 at 9:27
  • You can put it after the table. Commented May 13, 2016 at 9:28
  • @jcubic Thanks its working without ui-option. thanks a lot Commented May 13, 2016 at 9:37
  • @jcubic : can you please put your comment as an ans so that this question has accepted ans. Otherwise people will come to ans. Commented May 13, 2016 at 9:49

2 Answers 2

2

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

<div ng-hide="users.length">No Data Found</div>
Sign up to request clarification or add additional context in comments.

Comments

2

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>

2 Comments

your suggested ng-if and my ui-option both will work or just your .thanks.
<div ng-hide="users.length">No Data Found</div> it's working for me Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.