vendredi 22 mai 2015

Display all results when a checkbox is unchecked with angularjs filters

I'm just trying to do a simple thing which give me headache.

In an app with Angularjs, I have a dictionary with values. I want to filter my values using a checkbox. If the checkbox is checked, the list is refreshed with the elements which have is_streaming : TRUE. But if the checkbox is unchecked. I want to show all the results.

For the moment, when the checkbox is checked, it shows only the good events (it's exactly what I want) but when I uncheck, I have only the elements with FALSE.

var events = [{
    id: 0,
    event_name: 'Concert 1',
    is_streaming: 'true'
  }, {
    id: 1,
    event_name: 'Concert 2',
    is_streaming: 'true'
  },{
    id: 2,
    event_name: 'Concert 3',
    is_streaming: 'true'
  }



<ion-toggle ng-model="is_streaming" toggle-class="toggle-calm">En ce moment</ion-toggle>
<ion-list>
 <ion-item class="" ng-repeat="event in filtered=(events | filter:is_streaming)" type="item-text-wrap" href="#/tab/chats//{{event.id}}">
  <div class="player" ng-show="{{event.is_streaming}} == true"></div>
 </ion-item>
</ion-list>

Any help or advices will be good to hear. THX




Aucun commentaire:

Enregistrer un commentaire