title: angular iterate over json
body: <p>So I have a json and I am trying to get all the stats for active users only.  when I try to do in a for loop something like this </p>
  
  <pre><code>for(var i=0; i &lt; user.User.Stats.data.length; $i++;){
              return user.User.Stats[i].active === "1";    
  }
  </code></pre>
  
  <p>it doesn't work ...however works fine without for loop as long as I am getting only one record</p>
  
  <pre><code>return user.User.Stats[i].active === "1"; 
  </code></pre>
  
  <p>here is my html</p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
  &lt;div ng-repeat="user in _users | filter:isActive"&gt;
      {{user.User.userid}}
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>here is my js</p>
  
  <pre><code>var myApp = angular.module('myApp', []);
  
  function MyCtrl($scope) {
  
      $scope.isActive = function(user) {
         // for(var i=0; i &lt; user.User.Stats.data.length; $i++;){
              return user.User.Stats[0].active === "1";    
         // }
  
      };
  
      $scope._users = [
          {
          "User": {
              "userid": "19571",
              "status": "7",
              "active": "1",
              "lastlogin": "1339759025307",
              "Stats": [
                  {
                  "active": "1",
                  "catid": "10918",
                  "typeid": "71",
                  "Credits": [
                      {
                      "content": "917,65",
                      "active": "1",
                      "type": "C7"},
                  {
                      "content": "125,65",
                      "active": "1",
                      "type": "B2"}
                  ]},
                                  {
                  "active": "1",
                  "catid": "10918",
                  "typeid": "71",
                  "Credits": [
                      {
                      "content": "917,65",
                      "active": "1",
                      "type": "C7"},
                  {
                      "content": "125,65",
                      "active": "1",
                      "type": "B2"}
                  ]}
              ]
          }}];
  }
  </code></pre>
  
  <p>here is a demo link <a href="http://jsfiddle.net/4kzzy/174/" rel="noreferrer">http://jsfiddle.net/4kzzy/174/</a></p>