title: Loop through form array based on user input
body: <p>I have select menu with options if user select 1 then i have to display one form or if user select 2 i have to display 2 same forms but here if i push 2 forms after that push 3 it displays 5 forms total. What i have tried till now</p>
  
  <pre><code>&lt;select (change)="selectedvalue($event.target.value)"&gt;
    &lt;option *ngFor="let num of number" [value]="num.num"&gt;{{num.num}}&lt;/option&gt;
  &lt;/select&gt;
  &lt;br&gt;
  &lt;br&gt;
  
  &lt;div class="container"&gt;
  
      &lt;form [formGroup]="myForm"&gt;
  
          &lt;div formArrayName="addresses" &gt;
              &lt;div *ngFor="let address of myForm.controls.addresses.controls; let i=index" class="panel panel-default"&gt;
  
                  &lt;div [formGroupName]="i" class="myform"&gt;
                      &lt;label&gt;street&lt;/label&gt;
                      &lt;input type="text" class="form-control" formControlName="street"&gt;&lt;br&gt;&lt;br&gt;
                      &lt;label&gt;postcode&lt;/label&gt;
                      &lt;input type="text" class="form-control" formControlName="postcode"&gt;
                  &lt;/div&gt;&lt;br&gt;&lt;br&gt;
              &lt;/div&gt;
          &lt;/div&gt;&lt;br&gt;&lt;br&gt;
              &lt;pre&gt;form value: &lt;br&gt;{{myForm.value | json}}&lt;/pre&gt;
      &lt;/form&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>you can see full working example here <a href="https://stackblitz.com/edit/angular-bd8bsq?file=app%2Fapp.component.ts" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-bd8bsq?file=app%2Fapp.component.ts</a></p>
  
  <p>Thanks in advance.</p>