title: Angular: setErrors not working inside loop
body: <p>I have a <code>FormArray</code> whose fields I want to validate at once. I'm iterating over the <code>FormArray</code> and for each element (<code>FormGroup</code>), I'm checking a condition, disabling the valid <code>FormGroup</code>s to avoid the user changing it and setting error to a specific <code>FormControl</code> inside the <code>FormGroup</code>. </p>
  
  <p>Below is my code. <code>rows</code> is the <code>FormArray</code>.</p>
  
  <pre><code>response.forEach((item, index) =&gt; {
      if (item.detailName.valid &amp;&amp; item.detailNo.valid)
          (&lt;FormArray&gt;this.detailForm.get('rows')).at(index).disable({
              onlySelf: true
          });
      else if (!(item.detailName.valid &amp;&amp; item.detailNo.valid))
          if (!!item.detailName.value &amp;&amp; !item.detailNo.value)
              this.detailForm.get(['rows', index, 'detailName']).setErrors({
                  'invalidValue': true
              });
          else
              this.detailForm.get(['rows', index, 'detailNo']).setErrors({
                  'invalidValue': true
              });
  });
  </code></pre>
  
  <p>The error is not set as intended. That control is shown as <code>VALID</code> if I <code>console.log</code> it.</p>
  
  <p><strong>Update:</strong> Wrapped it by a <code>setTimeout</code> and it worked.</p>