lostintranslation lostintranslation - 3 months ago 48
AngularJS Question

ng-repeat filter on boolean

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

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/