title: Extract ng-message key from ng-messages
body: <p>I need to create a directive <em>myDirective</em> which reads all ng-message keys within it and it still creates a valid ng-messages element:</p>
  
  <p>Directive template:</p>
  
  <pre><code>&lt;div id="myDirective"&gt;
    &lt;div ng-messages="myform.$error" ng-transclude&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>&lt;my-directive&gt;
    &lt;div ng-message="required"&gt;something is required&lt;/div&gt;
    &lt;div ng-message="custom"&gt;custom validation&lt;/div&gt;
  &lt;/my-directive&gt;
  </code></pre>
  
  <p>So in this case I'd like to get an array of "required" and "custom". The problem is I cannot do that since all ng-messsage elements are already hidden (removed from the DOM to be more accurate) by the time my directive gets into its own linking function. How to get around this?</p>