title: Angular dynamically set ng-messages to name attribute
body: <p>I dynamically create inputs and want also validate every one of them but can't set correctly the <code>ng-messages</code> attribute to the field name property which is dynamically generated.</p>
  <pre><code>&lt;input ng-model=&quot;sub.name&quot; name=&quot;subName{{$index}}&quot; class=&quot;form-control&quot; placeholder=&quot;name&quot; required maxlength=&quot;20&quot; /&gt;
  &lt;div class=&quot;field-error&quot; ng-messages=&quot;form.subName{{$index}}.$error&quot; ng-show=&quot;form.Name.$touched&quot; role=&quot;alert&quot;&gt;
      &lt;div ng-message=&quot;required&quot;&gt;Name is required.&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>I got problem with second line where I set the <code>ng-messages</code> dynamically to <code>ng-messages</code>. How can I do this?</p>