title: Passing ng-model from view to controller angular js
body: <p>I am trying to pass value like this from view to controller in angular js of this form. I do not wish to hardcode it in this way. How could it be done in proper manner?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>angular.module('user').controller('UsersController', ['$scope', '$stateParams', 'Users',
   function($scope, $stateParams, Orders) {
    $scope.create = function() {
     var user = new Users({
      child: [
       { columnA: child[0].columnA, columnB: child[0].columnB, columnC: child[0].columnC },
       { columnB: child[1].columnA, columnB: child[1].columnB, columnC: child[1].columnC },
       ...
       { columnC: child[10].columnA, columnB: child[10].columnB, columnC: child[10].columnC }
      ]
     });
    }
   }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form data-ng-submit="create()"&gt;
    &lt;input type="text" data-ng-model="child[0].columnA"&gt;
    &lt;input type="text" data-ng-model="child[0].columnB"&gt;
    &lt;input type="text" data-ng-model="child[0].columnC"&gt;
  
    &lt;input type="text" data-ng-model="child[1].columnA"&gt;
    &lt;input type="text" data-ng-model="child[1].columnB"&gt;
    &lt;input type="text" data-ng-model="child[1].columnC"&gt;
    
    ......
  
    &lt;input type="text" data-ng-model="child[10].columnA"&gt;
    &lt;input type="text" data-ng-model="child[10].columnB"&gt;
    &lt;input type="text" data-ng-model="child[10].columnC"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It would be better if an reusable directive that may perform above function.</p>
  
  <pre><code>$scope.create = function() {
      child: toJSON(child);
  }
  
  function toJSON(var a) {
      //automatically search through the view for ng-model with child[index].columnName and change to the form above.
  }
  </code></pre>