Arjun Sarthi
Arjun Sarthi

Reputation: 109

Displaying 'No Data found' when there is no data, i.e., Null or undefined

I have a table where it shows list of employee Information in a table having few columns, I want to display 'No Data found', in a single row when there is no data coming from the server in angular 6

Upvotes: 0

Views: 373

Answers (2)

porgo
porgo

Reputation: 1737

Try this

<tbody>
  <tr *ngIf="location">
   <td>{{location.name}}</td>
   <td>{{location.id}}</td>
  </tr>
  <tr *ngIf="!location">
   <td colspan="2">No Data found</td>
  </tr>
</tbody>

Upvotes: 1

Prashant Pimpale
Prashant Pimpale

Reputation: 10717

Use colspan :

 <tr *ngIf="list.length == 0">
  <td colspan="number_of_columns_in_header"> No record found </th>
 </tr>

Upvotes: 0

Related Questions