title: Not Able To Set Dynamically Validator Inside FormGroup in FormArray - Angular
body: <p>I have one query in Angular Reactive Form.</p>
  
  <p>I have below formGroup, and inside that formGroup, I have a formArray, and inside that formArray, I have another formGroup.
  Here is the main formGroup</p>
  
  <pre><code>public formGroup = this.formBuilder.group({
      email: ["", Validators.required],
      address: this.formBuilder.array([
          this.initFun()
      ])
  });
  </code></pre>
  
  <p>Here is the formArray initFun() function</p>
  
  <pre><code>fun() {
      return this.formBuilder.group({
          city: [""],
          state: [""]
      });
  }
  </code></pre>
  
  <p>Now the query is I want to set the validator to city and state dynamically.</p>
  
  <p>What is the approach to add a dynamic validator to formArray inside formGroup?</p>
  
  <p>I can set the validator to email using below syntax:</p>
  
  <pre><code>this.formGroup.controls["email"].setValidators(Validators.required);
  </code></pre>
  
  <p>But I am not able to set validator for the city and state inside the address array.</p>
  
  <p>Any help would be highly appreciated :)</p>
  
  <p><strong><em>Update</em></strong></p>
  
  <p>I've created a sample of the above case you can check out here: <a href="https://stackblitz.com/edit/reactive-form-angular" rel="nofollow noreferrer">https://stackblitz.com/edit/reactive-form-angular</a></p>
  
  <p>Let me know if I am doing something wrong here.</p>