title: How to reference form field created by AngularJS formly
body: <p>I use Formly for creating my forms in angularJS</p>
  
  <p><strong>This is my field</strong></p>
  
  <pre><code>$scope.postFields = [
      {
          key: 'title',
          type: 'input',
          templateOptions: {
              label: "Title",
              // required: true,
              minlength: 2,
          },
          validation: {
              messages: {
                  required: function(viewValue, modelValue, scope) {
                      return scope.to.label + ' is required'
                  }
              }
          }
      }
  ]
  </code></pre>
  
  <p><strong>and I'm trying to access my fields as follows</strong></p>
  
  <pre><code>    function failure(response) {
      console.log("failure", response)
  
      _.each(response.data, function(errors, key) {
          _.each(errors, function(e) {
              $scope.form[key].$dirty = true;
              $scope.form[key].$setValidity(e, false);
          });
      });
  }
  </code></pre>
  
  <p><strong>my formly form</strong></p>
  
  <pre><code>&lt;formly-form form="postForm" model="model" fields="postFields" class="col-md-4"&gt;
      &lt;button type="submit" class="btn btn-primary" ng-click="addPost()"&gt;Submit&lt;/button&gt;
  &lt;/formly-form&gt;
  </code></pre>
  
  <p>but of course I'm getting this error:</p>
  
  <pre><code>TypeError: Cannot read property 'title' of undefined
  </code></pre>
  
  <p>it's on this line</p>
  
  <pre><code>$scope.form[key].$dirty = true;
  </code></pre>
  
  <p>do anyone of you know how to reference created formly fields the right way?</p>