title: TypeError: Cannot read property '$dirty' of undefined
body: <p>I have an Angular form with name <code>p24Form</code></p>
  
  <pre><code>&lt;div ng-form="private2" name="p24Form" ng-show="freqSelect == '2.4'" novalidate="" class="ng-pristine ng-valid"&gt;
      &lt;div class="form-group"&gt;
          &lt;label class="col-sm-2 control-label"&gt;
              &lt;span class="edit" data-pk="private_2"&gt;WiFi name&lt;/span&gt;:
          &lt;/label&gt;
          &lt;div class="col-sm-4"&gt;
              &lt;input type="text" class="form-control ng-pristine ng-untouched ng-valid" name="freq2_name" ng-model="ssid"&gt;
              &lt;!-- tooltips:  --&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am trying to detect if it is dirty or change, then showing my save button accordingly. 
  I tried </p>
  
  <h1>Try#1</h1>
  
  <pre><code>if ($scope.p24Form.$dirty) {
      alert('dirty');
      $scope.showSaveBtn = true;
  }else{
      $scope.showSaveBtn = false;
  }
  </code></pre>
  
  <h1>Try #2</h1>
  
  <pre><code>if ($scope.private2.$dirty) {
      alert('dirty');
      $scope.showSaveBtn = true;
  }else{
      $scope.showSaveBtn = false;
  }
  </code></pre>
  
  <p>I kept got </p>
  
  <blockquote>
    <p>TypeError: Cannot read property '$dirty' of undefined</p>
  </blockquote>
  
  <p>How can I debug this?</p>