angular2 - validating FormControlName in child component of parent FormGroup
<p>I have an angular component corresponding a form/page that is generating an indeterminate amount of child components, each representing an individual field, and I would like the parent component's FormGroup to validate the fields contained in the child components. Only when I do so, I get an error:</p>

<blockquote>
  <p>A FormControlName must have a corresponding FormGroup.</p>
</blockquote>

<p>Here is the template code for my parent component:</p>

<pre><code>&lt;div class="form-group" [formGroup]="parentGroup"&gt;
  &lt;table&gt;
    &lt;tbody&gt;
      &lt;tr *ngFor="let i of array"&gt;
        &lt;child [property]="i" [options]="myForm.controls[i.id]"&gt;&lt;/child&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>The form is defined in the component file here. I'm adding the FormControls according to how many child components we're adding:</p>

<pre><code>private formAttrs: FormGroup;

constructor(private _fb: FormBuilder) { }

ngOnInit() {
  this.myForm = this._fb.group({});
  for (var i = 0; i &lt; this.array.length; i++) {
    this.formAttrs.addControl(this.array[i].id, new FormControl(this.array[i].value, Validators.required));
  }
}
</code></pre>

<p>The template code for the child component is this:</p>

<pre><code>&lt;td class="prompt"&gt;
  {{i.label}}
&lt;/td&gt;
&lt;td class="required" width="1%"&gt;
  &lt;span *ngIf="property.required"&gt;*&lt;/span&gt;
&lt;/td&gt;
&lt;td&gt;
  &lt;input type="text " class="form-control" [ngClass]="{error: !options.valid}" formControlName="property.id"&gt;
&lt;/td&gt;
&lt;td&gt;
</code></pre>

<p></p>

<p>While there is nothing defined in the child component class (other than the "property" and the FormControl element passed down for "options"), I would think that the formGroup in the parent component would be able to match with the formControlName in the child component, but instead I get the error:</p>

<pre><code>EXCEPTION: Error in ./ChildComponent class ChildComponent - inline 
template:7:109 caused by: formControlName must be used with a parent 
formGroup directive.  You'll want to add a formGroup directive and pass 
it an existing FormGroup instance (you can create one in your class).
</code></pre>

<p>Is there a way I can get around this error? If not, is there another solution to this problem that someone can suggest?</p>

<p>Thanks in advance.</p>