Reputation: 999
I'm a beginner to angular 2 and unable to understand how to show a different div if list is empty.I have written and ngIf to check if data exists.Searched online and all results ask me to check length or use ! symbol but it does not work.Below is my github of the project and below it is the json result which i want to show list empty condition as well.
Json output
{"status_message":"Success","status_code":"0","Registers":null}
I was expecting to show a message called no data in List Component
Upvotes: 0
Views: 606
Reputation: 13416
Since your json returns a null instead of an empty string, you should be able to just do an ngIf check on that data point
<!-- list.component.html -->
<tbody>
<tr *ngFor='let lst of iproducts.Registers'>
...
</tr>
<tr *ngIf='!iproducts.Registers'>
<td colspan="3">No List Data Found</td>
</tr>
</tbody>
Upvotes: 1