Saturday, December 30, 2017

Error: Cannot find control with unspecified name attribute

Fix this Angular 4 error in reactive forms by removing some brackets. Something like this...

<tr *ngFor="let lineItem of presidentsForm.get('lineItems').controls; let i=index"
      [formGroupName]="i">
   <td><input type="text" [formControlName]="name" /></td>
   <td><input type="text" [formControlName]="party" /></td>
   <td><input type="checkbox" [formControlName]="hasNonconsecutiveTerms" /></td>
</tr>

 
 

...needs to become something like this:

<tr *ngFor="let lineItem of presidentsForm.get('lineItems').controls; let i=index"
      [formGroupName]="i">
   <td><input type="text" formControlName="name" /></td>
   <td><input type="text" formControlName="party" /></td>
   <td><input type="checkbox" formControlName="hasNonconsecutiveTerms" /></td>
</tr>

No comments:

Post a Comment