title: AngularJS - Get length of filtered array by ng-if
body: <p>I search a solution for this problem:</p>
  
  <p>When we use ng-if for filtered data in array (Created by ng-repeat), how can we get the length of filtered array?</p>
  
  <p>This is a crucial question, because if we know how to do that, we can know how many user are online, for example (I know we can found another solution for that, but I really want to know if we can get length of filtered array by ng-if).</p>
  
  <p>HTML :</p>
  
  <pre><code>&lt;div id="body"&gt;
    &lt;div ng-controller="startController"&gt;
      &lt;p ng-repeat="user in lists" ng-if="user.dispo == true"&gt;{{user.name}}&lt;/p&gt;
      Il y a {{lists.length}} membres connectées. &lt;br&gt; &lt;br&gt;
  
      (Normally, whe must have only 4 members online ...)
  
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS :</p>
  
  <pre><code>angular.module('app', [])
  
  .controller('startController', ['$scope', function($scope) {
  
    $scope.lists = [{
      id: 0,
      name: 'Ambre',
      situation: 'confirmed',
      lastText: 'Tu vas bien ?',
      dispo: true,
      face: 'img/girl1.jpg',
      age: 19,
      gender: 'female',
      inChat: false,
      description: ":p"
    }, {
      id: 1,
      name: 'Mélanie',
      lastText: 'J\'habite à Marseille !',
      situation: 'waiting',
      dispo: false,
      face: 'img/girl2.jpg',
      age: 21,
      gender: 'female',
      inChat: false,
      description: "Vive la vie ! "
    }, {
      id: 2,
      name: 'Lana',
      lastText: 'Ça marche à demain :)',
      situation: 'confirmed',
      dispo: true,
      face: 'img/girl3.jpg',
      age: 18,
      gender: 'female',
      inChat: true,
      description: "Je suis bavarde ! "
    }, {
      id: 3,
      name: 'Vicky',
      lastText: 'Serveuse et toi ?',
      situation: 'waiting',
      dispo: true,
      face: 'img/girl4.jpg',
      age: 22,
      gender: 'female',
      inChat: false,
      description: "Snap : Vickdng "
    }, {
      id: 4,
      name: 'Mina',
      lastText: 'Je ne sais pas ...',
      situation: 'confirmed',
      dispo: true,
      face: 'img/girl5.jpg',
      age: 26,
      gender: 'female',
      inChat: false,
      description: 'Jeune toulousaine ne cherchant rien en particulier. '
    }];
  
  }]);
  
  setTimeout(function() {
    angular.bootstrap(document.getElementById('body'), ['app']);
  });
  </code></pre>
  
  <p>I have create a JSFiddle here: <a href="http://jsfiddle.net/PositivProd/51bsbzL0/319/" rel="nofollow noreferrer">http://jsfiddle.net/PositivProd/51bsbzL0/319/</a></p>