title: Angular 6 - Looping through ng-template in child component with having reactive forms
body: <p>I have a main component that contains a child component within it. The main component looks as the following:</p>
  
  <pre><code>&lt;div&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;app-form-repeater [form]="form" [path]="'items'" [add]="customGroup"&gt;
        &lt;ng-template #content&gt;
            &lt;input formControlName="image" placeholder="Item name"&gt;
        &lt;/ng-template&gt;
    &lt;/app-form-repeater&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Within this component I have a main FormGroup named "form", within here I have a FormArray and within this array I have a FormGroup named "items" within this FormGroup I have a FormControl named "image".</p>
  
  <p>Now I want to loop in my "app-form-repeater" through the FormArray and display the results of my ng-template.</p>
  
  <p>My "app-form-repeater" looks as the following:</p>
  
  <pre><code>&lt;div [formGroup]="form"&gt;
    &lt;div formArrayName="items" *ngFor="let item of form.get('items').controls; let i = index;"&gt;
      &lt;div [formGroupName]="i"&gt;
        &lt;ng-template [ngTemplateOutlet]="content"&gt;&lt;/ng-template&gt;
      &lt;/div&gt;
  
      &lt;button class="btn btn--red btn--sm btn--round" (click)="removeItem(i)"&gt;-&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;button class="btn btn--blue" (click)="addItem()"&gt;New&lt;/button&gt; 
  </code></pre>
  
  <p>Everything works, I can create new items and it adds the new input. But there is one problem:</p>
  
  <pre><code>ERROR Error: Cannot find control with name: 'image'
  </code></pre>
  
  <p>This is because it does not use the FormGroup and FormArrayName and FormGroupName from the "app-form-repeater" component.</p>
  
  <p>Is there a way to fix this problem?</p>
  
  <p><strong>Added later:</strong></p>
  
  <ol>
  <li>It looks like ng-template uses parent FormArrayName but not
  where template is being loaded...</li>
  <li>Placing the input directyly in the "app-form-repeater" works
  but with the ng-template it doesn't.</li>
  </ol>