title: Angular form name is passed as string when passed as parameter
body: <p>I'm simply trying to reset a form using the angular functions <strong>$setPristine</strong> &amp; <strong>$setUntouched</strong> (several forms are created with ng-repeat).<br> 
  I assign the form name dynamically by using the syntax <strong>{{ someName }}</strong> (the name is build on the server side and is passed as json (string)).<br> 
  The name of the form is correctly assigned in the markup and validations are working as expected. The problem arrises when I pass that name as a parameter in the ng-click="reset(someName)" function.<br> 
  When debugging the name comes as a string and not as the form object which causes the error. I did a quick test by hard-coding the name and pass that same name and it works fine.<br>
  My assumption is, the name coming from json is a string and the type is forwarded to the function as is, instead of the object.<br> 
  So the question is: is there a way to convert that name so it is interpretated correctly by the controller. Or maybe there is something else I'm missing...</p>
  
  <p>Here is the markup ( notice the name of the form uses {{ resto.contactForm }} ):</p>
  
  <pre><code>&lt;form novalidate name="{{ resto.contactForm }}" ng-submit="submit(restoContact, resto.contactForm.$valid)" class="sky-form"&gt;
    &lt;div class="form-group"&gt;
      &lt;label class="checkbox state-success"&gt;
        &lt;input type="checkbox" ng-model="restoContact.sameAsUser" name="sameAsUser" id="sameAsUser" value="true" ng-click="contactAutoFill()"&gt;&lt;i&gt;&lt;/i&gt;Contact name is same as current user.
        &lt;input type="hidden" name="sameAsUser" value="false" /&gt;
      &lt;/label&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
       &lt;label class="control-label" for="contactName"&gt;Contact Name&lt;/label&gt;
       &lt;input type="text" ng-model="restoContact.contactName" name="contactName" id="contactName" placeholder="John, Doe" class="form-control" required /&gt;
         &lt;div ng-show="{{ resto.contactForm }}.contactName.$error.required &amp;&amp; !{{ resto.contactForm }}.contactName.$pristine" class="note note-error"&gt;Please enter a name or check the box 'Same as current user'.&lt;/div&gt;
     &lt;/div&gt;
     &lt;div class="form-group"&gt;
       &lt;label class="control-label" for="contactPhoneNumber"&gt;Contact Phone Number&lt;/label&gt;
       &lt;input type="text" ng-model="restoContact.contactPhoneNumber" name="contactPhoneNumber" id="contactPhoneNumber" placeholder="+1 555-1234-567" class="form-control" required ng-pattern="phoneNumberPattern" /&gt;
         &lt;div ng-show="({{ resto.contactForm }}.contactPhoneNumber.$error.required || {{ resto.contactForm }}.contactPhoneNumber.$error.pattern) &amp;&amp; !{{ resto.contactForm }}.contactPhoneNumber.$pristine" class="note note-error"&gt;Please enter a valid phone number.&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="margin-leftM19"&gt;
        &lt;button class="btn btn-primary"&gt;Save Changes &lt;/button&gt;
        &lt;button class="btn btn-default" ng-click="reset(resto.contactForm)"&gt;Cancel &lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the reset function in the controller (form comes as "contactForm1" which is the correct name but is a string and not the object):</p>
  
  <pre><code>$scope.reset = function (form) {            
          if (form) {
              form.$setPristine();
              form.$setUntouched();
          }
          //$scope.user = angular.copy($scope.master);
      };
  </code></pre>
  
  <p>I have not implemented th submit method but I'm sure I will be running into the same issue.
  Any suggestions or advices are welcome.
  Thanks in advance...</p>
  
  <p>Here is the fidle.js. the variable data is an exact response from the server.<br>
  [<a href="http://jsfiddle.net/bouchepat/v0mtbxep/]" rel="nofollow">http://jsfiddle.net/bouchepat/v0mtbxep/]</a><br></p>
  
  <p><strong>SOLUTION</strong>:<br><br>
  <a href="http://jsfiddle.net/bouchepat/v0mtbxep/3/" rel="nofollow">http://jsfiddle.net/bouchepat/v0mtbxep/3/</a>
  <br>
  I removed $setUntouched as it throws an error.</p>