ngHide or ngShow based on number of children

To add to @Josh David Miller answer, the following values are considered falsy in angular.

1)An Empty Array

2)An Empty String //Even a space is considered true

3)An Boolean with false

4)undefined

5)null

6) 0

So, David’s answer can be written as,

<div ng-show="items.length">
  <div ng-repeat="item in items">
    <!-- ... -->
  </div>
</div>

or even shorter,

<div ng-show="items">
  <div ng-repeat="item in items">
    <!-- ... -->
  </div>
</div>

Leave a Comment

tech