title: Binding input fields to Array in Angularjs
body: <p>i have this simple problem that i can't really found a solution for it. so what i am willing to do is inserting to an array values from inputs. </p>
  
  <p>so for example i have this empty array at my controller first : </p>
  
  <pre><code>   $scope.contents =  [
      {name: "", value: ""}
   ] ; 
  </code></pre>
  
  <p>and i have three input fields that each of them has a label and a value : </p>
  
  <pre><code>    &lt;label&gt;1st Label&lt;/label&gt;
      &lt;input type='text' value='1st Value' /&gt;
  
      &lt;label&gt;2nd Label&lt;/label&gt;
      &lt;input type='text' value='2nd Value' /&gt;
  
      &lt;label&gt;3rd Label&lt;/label&gt;
      &lt;input type='text' value='3rd Value' /&gt;
  </code></pre>
  
  <p>i want by clicking a button to add the label and the value of each input to the array and  i want the ng-model name of the values and labels to be generated automatically so in the ng-model i want to put something like this <code>ng-model=val[$index]</code> that iterates </p>
  
  <p>so the result should be </p>
  
  <pre><code>   $scope.contents =  [
          {label: "1st Label", value: "1st Value"},
          {label: "2nd Label", value: "2nd Value"},
          {label: "3rd Label", value: "3rd Value"}
      ] ; 
  </code></pre>
  
  <p>Any help will be appreciated</p>