Issue
I am trying to do this
{% if collection %}
<tr ng-repeat="items in collection">
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
{% else %}
<tr>
<td colspan="3">No items in collection</td>
</tr>
{% endif %}
but I am getting an error saying collection variable is not defined. What's the correct syntax to do that?
Solution
Try below snippet
<tbody ng-if="collection.length > 0">
<tr ng-repeat="items in collection">
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
</tbody>
<tbody ng-if="!collection || collection.length==0">
<tr>
<td colspan="3">No items in collection</td>
</tr>
</tbody>
Answered By - Prakash Jethava
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.