title: How to use an Angular variable to control the index of an angular array?
body: <p>I need to show some information about an item, and if I click in a list of other items the information must change (not the case right now).</p>
  
  <p>To show the first item of an array is easy if I use 0 between [ ], but if I try to use the $scope.id = 0, nothing happens.</p>
  
  <p>HTML:</p>
  
  <pre><code>                    &lt;div class="col-md-5"&gt;
                          &lt;b&gt;{{faturas[{{id}}].faturan}}&lt;/b&gt;
                          &lt;p&gt;Vencimento: &lt;span&gt;{{faturas[{{id}}].venc}}&lt;/span&gt;&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;div class="col-md-7"&gt;
                          &lt;p&gt;Período: {{faturas[{{id}}].ini}} a {{faturas[{{id}}].fim}}&lt;/p&gt;
                          &lt;p&gt;Valor: R$ &lt;span&gt;{{faturas[{{id}}].valor}}&lt;/span&gt;&lt;/p&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>Node:</p>
  
  <pre><code>var queryString = 'SELECT * from faturas WHERE empID = '+usuarioSession.empID;
  connection.query(queryString,function(err,rows)     {  
      var ret = [];              
      for (var i = 0; i &lt; rows.length; i++) {                        
          ret.push ({
              index: i,
              faturan: "Fatura "+(i+1),
              venc: rows[i].fatDataVenc,
              ini: rows[i].fatDataIni,
              fim: rows[i].fatDataFim,
              valor: rows[i].fatValor
          });
  
      }         
      response.writeHead(200, {'Content-Type': 'application/json'});
      response.end(JSON.stringify(ret), 'utf-8');
  });
  </code></pre>
  
  <p>Angular:</p>
  
  <pre><code>app.controller('faberto',function($scope,$http){
      $scope.id = 0;
      $http.get('/servico/faberto').success(function(data) {
          $scope.faturas = angular.fromJson(data);
  
      });
  });
  </code></pre>