title: How ng-message is connected to model, and how can I show the message using ng-message?
body: <p><a href="https://plnkr.co/edit/T2t5fxlj82GOZ1pcMqcs?p=preview" rel="nofollow noreferrer">In this plunk</a> the objective is to show an error message based on validation in the controller (instead of the built-ins <code>required</code> or <code>min-length</code>). The message error does not display when the ng-message-exp is set.</p>
  <p>Any idea on how to make this work or better how <code>ng-message</code> actually works which is tied to the error or model?</p>
  <p>HTML</p>
  <pre><code>&lt;body ng-app=&quot;ngMessagesExample&quot; ng-controller=&quot;ctl&quot;&gt;
    
    &lt;form name=&quot;myForm&quot; novalidate ng-submit=&quot;submitForm(myForm)&quot;&gt;
      &lt;label&gt;
        This field is only valid when 'aaa' is entered  
        &lt;input type=&quot;text&quot;
               ng-model=&quot;data.field1&quot;
               name=&quot;field1&quot; /&gt;
      &lt;/label&gt;
      &lt;div ng-messages=&quot;myForm.field1.$error&quot; style=&quot;color:red&quot;&gt;
          &lt;div ng-message-exp=&quot;validationError&quot;&gt;this is the error&lt;/div&gt;
      &lt;/div&gt;
    
    &lt;br/&gt;&lt;br/&gt;
    &lt;button style=&quot;float:left&quot; type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Javascript</p>
  <pre><code>var app = angular.module('ngMessagesExample', ['ngMessages']);
  
  app.controller('ctl', function ($scope) {
    
    $scope.submitForm = function(form) {
      
      if (form.field1.$modelValue != 'aaa') {
          $scope.validationError = true;
          console.log('show error');
      }
      else {
          $scope.validationError = false;
          console.log('don\'t show error');
      }
    };
    
    
  });
  </code></pre>