title: Generate dynamic form input fields and collect field data in an array
body: <p>I am stuck with this little task.
  I need to generate form input fields dynamically by clicking 'add' button on the form.
  The form is supposed to create DB table schema. So every input field is a DB table field name.</p>
  
  <p>I am OK generating the fields dynamically but have trouble with gathering the actual data.</p>
  
  <pre><code>&lt;form ng-controller="NewTableCtrl" ng-submit="submitTable()"&gt;
    &lt;input type='text' ng-model='table.title' placeholder='Title:'&gt;
    &lt;input ng-repeat="field in fields" type='text' ng-model='table.fields' placeholder='Field:'&gt;
    &lt;div&gt;
      &lt;button type='submit'&gt;Submit&lt;/button&gt;
      &lt;button ng-click="addFormField()"&gt;Add&lt;/button&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>.. and the controller</p>
  
  <pre><code>.controller('NewTableCtrl', function($scope) {
    $scope.fields = [];
    $scope.table = {};
  
    $scope.addFormField = function () {
      $scope.fields.push({});
    }
  
    $scope.submitTable = function () {
      console.log($scope.table);
    }
  });
  </code></pre>
  
  <p>Looks simple. When I click 'Add' button it generates the new input field but it does it with the same model object (obveously). And that's where my misunderstanding lies. I thought that if I declare <code>$scope.fields = [];</code>in the controller then repeating field data will just go into the array. But it just echoes the input in every repeating input field. I understand now that this is how it is supposed to be with two way binding.</p>
  
  <p>The reason I thought like this is by the analogy with an ordinary form submission where the repeating input field names become an array in the URL encoded form data.</p>
  
  <p>So how do I solve this? The server needs to get an array of fields like this: <code>fields: [field1, field2 ...]</code> Do I need to generate input fields with different scope variable for each field? How do I do this?</p>
  
  <p>Is this more complex then I thought and it needs to be a directive? If yes, please, show me how to do this.</p>
  
  <p>Thanks.</p>