title: How to push to a FormArray([ ]) in angular 4
body: <p>I have a reactive angular form that looks something like this.</p>
  
  <pre><code> &lt;form [formGroup]="myForm"&gt;
        &lt;div *ngFor="let Repo of Repos;"&gt;
             &lt;fieldset&gt;
                  &lt;legend&gt;{{Repo.name}}&lt;/legend&gt;
                      &lt;div class="checkbox checkbox-success"&gt;
                         &lt;input
                              [id] = "Repo.id"
                              type="checkbox"   (change)="onChange(Repo.User,Repo.Commits,Repo.Requests,Repo.Contributors, Repo.Languages,Repo.Branches,Repo.Langs,$event.target.checked)"&gt;
                                &lt;label [for] = "Repo.id"&gt;
                                   Select This Repository
                                &lt;/label&gt;
                       &lt;/div&gt;
              &lt;/fieldset&gt;
         &lt;/div&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>Following is the typescript file: </p>
  
  <pre><code>export class AddUserComponent implements OnInit {
        githubUserResponse;
        githubReposResponse;
        myForm = new FormGroup({});
      ngOnInit(){
         this.myForm = new FormGroup({
              'userRepoData' : new FormGroup({
                'githubusers': new FormGroup({
                  'username': new FormControl(null),
                  'html_url': new FormControl(null),
                  'name': new FormControl(null),
                  'company': new FormControl(null),
                  'location': new FormControl(null),
                  'user_created_at': new FormControl(null),
                  'user_updated_at': new FormControl(null),
                  'public_repos': new FormControl(null),
                  'public_gists': new FormControl(null),
                  'githubrepos': new FormArray([]),
                }),
              }),
            });
      }
  onChange(repo, commits, requests, contributors, branches, langs,  isChecked: boolean){
          if (!isChecked) {
           console.log('aayaa');
           (&lt;FormArray&gt;this.myForm.get('userRepoData.githubusers.githubrepos')).push(
             new FormGroup({
               'owner': new FormControl(repo.owner.login),
               'name': new FormControl(repo.name),
               'html_url': new FormControl(repo.html_url),
               'clone_url': new FormControl(repo.clone_url),
               'repo_created_at': new FormControl(repo.created_at),
               'repo_updated_at': new FormControl(repo.updated_at),
               'repo_pushed_at': new FormControl(repo.pushed_at),
               'public_repos': new FormControl(repo.public_repos),
               'no_of_commits': new FormControl(commits.length),
               'no_of_branches': new FormControl(branches.length),
               'no_of_pullrequests': new FormControl(requests.length),
               'no_of_contributors': new FormControl(contributors.length),
               'repobranches': new FormArray([]), //empty
               'repocommits': new FormArray([]), //empty
               'repocontributors': new FormArray([]), //empty
               'repolangs': new FormArray([]), //empty
               'repo_p_rs': new FormArray([]) //empty
             })
           );
           console.log(this.myForm.value);
    }
  }
  </code></pre>
  
  <p>it can be seen in above FormGroup that the FormArrays :<br>
     1. repobranches<br>
     2. repocommits<br>
     3. repocontributors<br>
     4. repolang<br>
     5. repo_pr_s<br>
  are empty.
  now i want to push some arrays within these nested FormArrays.</p>
  
  <p>for example following is the array i want to push to 'repocontributors' :</p>
  
  <pre><code>[
                      {
                          "login": "Saurabh0606",
                          "id": 21239899,
                          "avatar_url": "https://avatars2.githubusercontent.com/u/21239899?v=4",
                          "gravatar_id": "",
                          "url": "https://api.github.com/users/Saurabh0606",
                          "html_url": "https://github.com/Saurabh0606",
                          "followers_url": "https://api.github.com/users/Saurabh0707/followers",
                          "following_url": "https://api.github.com/users/Saurabh0707/following{/other_user}",
                          "gists_url": "https://api.github.com/users/Saurabh0707/gists{/gist_id}",
                          "starred_url": "https://api.github.com/users/Saurabh0707/starred{/owner}{/repo}",
                          "subscriptions_url": "https://api.github.com/users/Saurabh0707/subscriptions",
                          "organizations_url": "https://api.github.com/users/Saurabh0707/orgs",
                          "repos_url": "https://api.github.com/users/Saurabh0707/repos",
                          "events_url": "https://api.github.com/users/Saurabh0707/events{/privacy}",
                          "received_events_url": "https://api.github.com/users/Saurabh0707/received_events",
                          "type": "User",
                          "site_admin": false,
                          "contributions": 2
                      }
  
  
  {
                              "login": "Saurabh0707",
                              "id": 21239898,
                              "avatar_url": "https://avatars2.githubusercontent.com/u/21239898?v=4",
                              "gravatar_id": "",
                              "url": "https://api.github.com/users/Saurabh0707",
                              "html_url": "https://github.com/Saurabh0707",
                              "followers_url": "https://api.github.com/users/Saurabh0707/followers",
                              "following_url": "https://api.github.com/users/Saurabh0707/following{/other_user}",
                              "gists_url": "https://api.github.com/users/Saurabh0707/gists{/gist_id}",
                              "starred_url": "https://api.github.com/users/Saurabh0707/starred{/owner}{/repo}",
                              "subscriptions_url": "https://api.github.com/users/Saurabh0707/subscriptions",
                              "organizations_url": "https://api.github.com/users/Saurabh0707/orgs",
                              "repos_url": "https://api.github.com/users/Saurabh0707/repos",
                              "events_url": "https://api.github.com/users/Saurabh0707/events{/privacy}",
                              "received_events_url": "https://api.github.com/users/Saurabh0707/received_events",
                          "type": "User",
                          "site_admin": false,
                          "contributions": 2
                      }
                  ]   
  </code></pre>
  
  <p>similarly others also.</p>
  
  <p>how am i supposed to do this..?<br>
  Help Required.<br>
  Thanks In Advance.<br></p>