0

I have a ionic list which shows the checked items from another list, but I want to show a message if the list is empty.

The code is:

<ion-item ng-repeat='(place, checked) in localStorage.options' ng-if="checked" class="item item-body">

How would I do the ng-show, as this is not the standard ng-repeat.

rob
  • 291
  • 3
  • 9
  • 21

1 Answers1

0

try this :

Controller:

$scope.isEmptyObjectEmpty = function(object) {
        for(var i in object) {
            return true;
        }
        return false;
    };

Html:

<div class="item item-text-wrap"
     ng-if="!isEmptyObjectEmpty(localStorage.options)">
               list is empty(msg)
</div>
the_mahasagar
  • 1,201
  • 2
  • 16
  • 24
  • Hi, that works if the localStorage is empty, but what I want is, if the list is empty as well. – rob Mar 22 '16 at 09:32
  • i didnt got..!means there is no other list in your ques..!to check..update your ques properly..!which list..? – the_mahasagar Mar 22 '16 at 09:39
  • for example the localStorage saves the list but what about when the list is empty. The message is not displayed – rob Mar 22 '16 at 09:52
  • try with ng-if="!isEmptyObjectEmpty(localStorage.options) || localStorage.list.length < 0" – the_mahasagar Mar 22 '16 at 10:00
  • Update your ques with controller code, data (localstorage) , and complete html . Its hard to guess your problem, what your are trying your side..!help yourself..! – the_mahasagar Mar 22 '16 at 10:14