ng-repeat filter on boolean

lostintranslation picture lostintranslation · Jul 15, 2013 · Viewed 67.3k times · Source

I am trying to filter on a boolean value in an ng-repeat.

List of unregistered users:

    <h3>Unregistered Users</h3>
    <div ng-repeat="user in users | filter:!user.registered">
        <div class="row-fluid">
        <div class="span2">
          {{user.name}}
        </div>
      </div>
    </div>

List of registered users:

    <h3>Registered Users</h3>
    <div ng-repeat="user in users | filter:user.registered">
        <div class="row-fluid">
        <div class="span2">
          {{user.name}}
        </div>
      </div>
    </div>

Is there a good way to filter based on registered and !registered.

Answer

alfrescian picture alfrescian · Jul 15, 2013

filter by obj expression:

<h3>Unregistered Users</h3>
<div ng-repeat="user in users | filter:{registered:false}">
    <div class="row-fluid">
    <div class="span2">
      {{user.name}}
    </div>
  </div>
</div>

JSFiddle: http://jsfiddle.net/alfrescian/9ytDN/