title: Validate custom directive using ngMessages
body: <p>I writing a web app in angularjs and using <a href="https://material.angularjs.org/latest/#/" rel="noreferrer">angular material</a> (not sure if that is relevant to the question) and <a href="https://docs.angularjs.org/api/ngMessages/directive/ngMessages" rel="noreferrer">ngMessages</a> to provide feedback for invalid inputs to the user.</p>
  
  <p>Usually, for validation of directives provided, I can validate in a way similar to:</p>
  
  <pre><code>&lt;md-input-container&gt;
      &lt;input required name="myInput" ng-model="someModel"&gt;
      &lt;div ng-messages="formName.myInput.$error"&gt;
          &lt;div ng-message="required"&gt;This field is required.&lt;/div&gt;
      &lt;/div&gt; 
  &lt;/md-input-container&gt;
  </code></pre>
  
  <p>But if I created my own custom directive...</p>
  
  <pre><code>moduleName.directive('ngCustomdir', function(){
      return {
          restrict: 'A',
          require: 'ngModel',
          link: function($scope, $element, $attrs, ngModel){
              //do some validation
              return validation; //&lt;--true or false based on validation
          }
      };
  }
  </code></pre>
  
  <p>and include it in my input...</p>
  
  <pre><code>&lt;input required ng-customdir name="myInput" ng-model="someModel"&gt;
  </code></pre>
  
  <p>I know it validates the input, because if the input is invalid based on my custom directive's validation, the field turns red and the $invalid value is set to true, but I do not know how to make a message appear with ngMessages based on when this happens.  </p>
  
  <pre><code>&lt;div ng-messages="formName.myInput.$error"&gt;
      &lt;div ng-message="required"&gt;This field is required.&lt;/div&gt;
      &lt;div ng-message="customdir"&gt;This is what I need to appear.&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I cannot seem to get a message to appear when my custom directive validation is invalid.  How do I do this?
  Thanks for the help in advance.</p>