title: If ngModel is used within a form tag set name or set standalone error
body: <p>I've just started developing my first Angular 2 app and I got the following confusing error message:</p>
  <blockquote>
  <p>Error: If ngModel is used within a form tag, either the name attribute
  must be set or the form
  control must be defined as 'standalone' in ngModelOptions.</p>
  <p>Example 1: &lt;input [(ngModel)]=&quot;person.firstName&quot; name=&quot;first&quot;&gt;
  Example 2: &lt;input [(ngModel)]=&quot;person.firstName&quot; [ngModelOptions]=&quot;{standalone: true}&quot;&gt;</p>
  </blockquote>
  <p>This is where I get the error:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;button (click)=&quot;addRow()&quot; class=&quot;btn&quot;&gt;A&amp;ntilde;adir&lt;/button&gt;
  &lt;form #productionOrderForm=&quot;ngForm&quot; (ngSubmit)=&quot;onSubmit()&quot;&gt;
      &lt;table class='table' *ngIf=&quot;productionorders?.length &gt; 0&quot;&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Nombre&lt;/th&gt;
                  &lt;th&gt;Num. items primer nivel&lt;/th&gt;
                  &lt;th&gt;Reducci&amp;oacute;n&lt;/th&gt;
                  &lt;th&gt;Legislaci&amp;oacute;n&lt;/th&gt;
                  &lt;th&gt;Producto&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr *ngFor=&quot;let productionorder of productionorders; let rowIndex = index&quot;&gt;
                  &lt;td&gt;
                      &lt;input name=&quot;Name-{{rowIndex}}&quot; #name=&quot;ngModel&quot; [(ngModel)]=&quot;productionorder.name&quot; placeholder=&quot;Nombre&quot; required&gt;
                      &lt;div *ngIf=&quot;name.invalid &amp;&amp; (name.dirty || name.touched)&quot; class=&quot;alert alert-danger&quot;&gt;
                          &lt;div *ngIf=&quot;name.errors.required&quot;&gt;
                              Obligatorio.
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input name=&quot;NumItems-{{rowIndex}}&quot; #numitems=&quot;ngModel&quot; [(ngModel)]=&quot;productionorder.numitems&quot; placeholder=&quot;Items por nivel&quot; required&gt;
                      &lt;div *ngIf=&quot;numitems.invalid &amp;&amp; (numitems.dirty || numitems.touched)&quot; class=&quot;alert alert-danger&quot;&gt;
                          &lt;div *ngIf=&quot;numitems.errors.required&quot;&gt;
                              Obligatorio.
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;law (notifyParent)=&quot;getNotification($event)&quot;&gt;&lt;/law&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;select [(ngModel)]=&quot;productionorder.productid&quot; #productId=&quot;ngModel&quot;&gt;
                          &lt;option&gt;&lt;/option&gt;
                          &lt;option *ngFor=&quot;let product of products&quot; [value]=&quot;law.lawId&quot;&gt;{{law.name}}&lt;/option&gt;
                      &lt;/select&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
      &lt;button *ngIf=&quot;productionorders?.length &gt; 0 &amp;&amp; law != ''&quot; type=&quot;submit&quot; class=&quot;btn btn-success&quot; [disabled]=&quot;disableSubmit()&quot;&gt;Guardar cambios&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>I get the error at this line:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div *ngIf=&quot;numitems.invalid &amp;&amp; (numitems.dirty || numitems.touched)&quot; class=&quot;alert alert-danger&quot;&gt;
  </code></pre>
  <p>But the error message is confuse because I have set the name in the input field:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;input name=&quot;NumItems-{{rowIndex}}&quot; #numitems=&quot;ngModel&quot; [(ngModel)]=&quot;productionorder.numitems&quot; placeholder=&quot;Items por nivel&quot; required&gt;
  </code></pre>
  <p>The others input in this form have the same structure and I don't get any error in them.</p>
  <p>Where is this error coming from? How can I fix it?</p>