title: AngularJS Cannot read property '$setPristine' of undefined
body: <p>I'm getting the error Cannot read property '$setPristine' of undefined when attempting to reset a form. </p>
  
  <p>My controller:</p>
  
  <pre><code>formApp.controller('FormController', ['$scope', 
      function ($scope) {
  
          $scope.options = ["Opt1", "Opt2", "Opt3", "Other"];
          $scope.formData = {
              selectedOption: null,
              firstName: "",
              lastName: "",
              email: "",
              phone: "",
              fax: "",
              comments: ""
          };
  
          var origData = angular.copy($scope.formData);
  
  
          $scope.submit = function () {
              // submit code goes here
          };
  
          $scope.reset = function () {
              $scope.formData = angular.copy(origData);
  
                //  $scope.financeForm.$setUntouched();
                  $scope.financeForm.$setPristine();
  
  
          };
  
          $scope.reset();
  
      }
  ]);
  </code></pre>
  
  <p>My HTML (I've stripped out most fields to keep this minimal):</p>
  
  <pre><code>&lt;form id="financeForm" name="financeForm" ng-submit="financeForm.$valid &amp;&amp; submit()" novalidate&gt;
      &lt;md-content layout-padding class="autoScroll"&gt;
          &lt;md-input-container flex md-is-error="financeForm.selectedOption.$invalid &amp;&amp; (financeForm.$submitted || financeForm.selectedOption.$dirty)"&gt;
              &lt;md-select required placeholder="Nature of your Enquiry" ng-model="formData.selectedOption" name="selectedOption" id="selectedOption"&gt;
                  &lt;md-option ng-repeat="opt in options" value="{{opt}}"&gt;{{opt}}&lt;/md-option&gt;
              &lt;/md-select&gt;
              &lt;div ng-messages="financeForm.selectedOption.$error" ng-if="financeForm.$submitted || financeForm.selectedOption.$touched"&gt;
                  &lt;div ng-message="required"&gt;Please your enquiry option.&lt;/div&gt;
              &lt;/div&gt;
          &lt;/md-input-container&gt;
  
          &lt;md-input-container&gt;
              &lt;label&gt;Comments&lt;/label&gt;
              &lt;textarea ng-model="formData.comments" columns="1" md-maxlength="500"&gt;&lt;/textarea&gt;
          &lt;/md-input-container&gt;
      &lt;/md-content&gt;
  
      &lt;md-button class="md-raised" ng-click="reset();"&gt;RESET&lt;/md-button&gt;
      &lt;md-button class="md-raised md-primary"&gt;SUBMIT&lt;/md-button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I don't see what I'm doing wrong. Can someone please help?</p>