title: nested and dynamically created ng-model into ng-repeat
body: <p>I know there is a lot of question about this problem but i couldn't resolve my problem.</p>
  
  <p>the final outcome of my project is to create a xml file.</p>
  
  <p>For this i need to ask the user to chose a root node and depending on his choice i send a request to my db to retrieve possible children of this root node. Then he chose the child he wants and i sent another request to retrieve possible children for this node and so on until i reach a leaf.</p>
  
  <p>So i need to make drop down list appears dynamically. But to be able to create the xml i need to save every choice he made so i need to keep the selected node in separate ng-model.</p>
  
  <p>Based on other questions and and their answers i tried this : </p>
  
  <p>html: </p>
  
  <pre><code>    &lt;select ng-model='selectedstandard' ng-options='item for item in standard' ng-change="getTypes()"&gt;
          &lt;option value=""&gt;select standard&lt;/option&gt;
      &lt;/select&gt;
  
      &lt;select ng-model='selectedstandard[$index]' ng-options='item for item in standard' ng-change="getTypes()" ng-repeat="node in nodes"&gt;
          &lt;option value=""&gt;select standard&lt;/option&gt;
      &lt;/select&gt;
  </code></pre>
  
  <p>maincontroller.js : </p>
  
  <pre><code>$scope.nodes=[];
  $scope.getTypes = function(){
    $scope.types = $http({
       method: 'GET',
       url: 'http://localhost:8080/hello/types',
       headers: {'Content-Type': 'application/json', 'standard' : $scope.selectedstandard}
       }).success(function (data) 
       {
           $scope.types=data;
           var i=0;
           var simpleTypesTemp = JSON.parse(JSON.stringify($scope.types));
           for(var ty in $scope.types){
           var valuetab=($scope.types[ty]).split(":");
           simpleTypesTemp[ty]= valuetab[0]+":...:"+valuetab[(valuetab.length)-1];
       }
   });
   if($index){
      $scope.nodes.push($scope.selectedstandard[$index]);
   }
   else{
      $scope.nodes.push($scope.selectedstandard);
    }
    $scope.getNameSpace();
  }
  </code></pre>
  
  <p>But i get an error telling me $index isn't defined.</p>
  
  <p>I guess the two ng-model named selectedstandard and selectedstandard[$index] is not a very good idea but i need to initialize the loop a way or another.</p>