title: Cannot find control with path in angular
body: <p>I am using angular 6 application and using dynamic forms.</p>
  
  <p>app.component.html:</p>
  
  <pre><code>   &lt;form (ngSubmit)="onSubmit()" [formGroup]="form"&gt;
      &lt;div formArrayName="multiDynamic"&gt;
        &lt;!-- row --&gt;
        &lt;div *ngFor="let record of form.controls.multiDynamic.controls; let i=index"&gt;
              &lt;div class="row" [formGroupName]="i"&gt;
                  &lt;div class="col-md-6" *ngFor="let question of model.questions"&gt;
                      &lt;div [ngSwitch]="question.controlType"&gt;
                          &lt;div class="form-group form-black label-floating"&gt;
                              &lt;label class="control-label"&gt;{{question.text | titlecase}} &lt;/label&gt;
                              &lt;div *ngSwitchCase="'textbox'"&gt;&lt;input type="text" class="form-control" [formControlName]="question.key"&gt;&lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;button type="submit&gt; Submit &lt;/button&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>app.component.ts:
      import { Component, OnInit, Input } from '@angular/core';
      import { FormBuilder, FormGroup, Validators, FormControl, FormArray } from '@angular/forms';</p>
  
  <pre><code>export class AppComponent implements OnInit {
   @Input() model: any;
  form: FormGroup;
  
  ngOnInit() {
  
  this.sharedService.getData().subscribe(data =&gt; {
    this.items = data;
    console.log(this.items);
  });
  
  this.form = this.fb.group({
          multiDynamic: this.fb.array([
            this.model.toGroup()
          ])
        });
    }
  
  }
  </code></pre>
  
  <p>console.log(model.questions) gives the following (expanded array),</p>
  
  <pre><code>0:Textbox {controlType: "textbox", key: "url-links", text: "url-links"}
  1:Textbox {controlType: "textbox", key: "//input[@id='rcmloginuser']", text: "//input[@id='rcmloginuser']"}
  2:Textbox {controlType: "textbox", key: "//input[@id='rcmloginpwd']", text: "//input[@id='rcmloginpwd']"}
  3:Textbox {controlType: "textbox", key: "//input[@id='rcmloginsubmit'] ", text: "//input[@id='rcmloginsubmit'] "}
  </code></pre>
  
  <p>I am using the above html and ts files and if i give this line,</p>
  
  <pre><code>&lt;input id="i" type="text" class="form-control" [formControlName]="question.text"&gt;
  </code></pre>
  
  <p>i am getting error as, 
  <strong>Cannot find control with path: 'multiDynamic -> 0 -> url-links'</strong></p>
  
  <p>In label,</p>
  
  <pre><code>&lt;label class="control-label"&gt; {{question.text | titlecase}} &lt;/label&gt;
  </code></pre>
  
  <p>the text value is getting displayed but if i give formControlName in input box, then i am getting this error.</p>
  
  <p>I am using angular's dynamic form.</p>
  
  <p><code>this.model.toGroup()</code> is having the following,</p>
  
  <pre><code>export class DynamicFormMultiModel {
      questions = [];
  multiDataResponse: any = [];
  form: FormGroup;
  
  toGroup() {
      const group: any = {};
      this.questions.forEach((question) =&gt; {
          group[question.key] = new FormControl('');
      });
  
      return new FormGroup(group);
  }
  
      patchData() {
          const arrayGroup: any = {};
          const dataRes: any = [];
          const resObj: any = {};
  
          // this.multiDataResponse.forEach((element, index) =&gt; {
          //     this.questions.forEach((question, inx) =&gt; {
          //             arrayGroup[question.key] = new FormControl(element[question.key]);
          //     });
          // });
          resObj['data'] = this.multiDataResponse;
  
      // return new FormGroup(arrayGroup);
      return resObj;
      }
  }
  </code></pre>
  
  <p>As i am having nested codes i am unable to post the entire code but i am getting data and its displaying in label but the input tag is throwing error. (Both contains same value <code>question.text</code>).</p>
  
  <p>Attached the screenshot of the scenario.</p>
  
  <p><a href="https://i.stack.imgur.com/Pqodi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pqodi.png" alt="enter image description here"></a></p>
  
  <p>Kindly help me to fix this stucked for too long time in it..</p>