title: Reactive form in angular 4 submit array of checkbox values on click of button
body: <p>I am developing an app in Angular 4. I am using Reactive forms. I am building a simple submit form like below:</p>
  
  <pre><code>&lt;form [formGroup]="newPostForm" novalidate&gt;
  
        &lt;input formControlName="Title" type="text" class="form-control" id="txtTitle" placeholder="Enter title of post..."&gt; 
          &lt;h4&gt;Categories&lt;/h4&gt;
          &lt;ul&gt;
            &lt;li *ngFor="let cat of catsList"&gt;
              &lt;span style="margin-top: -2.5px;"&gt;
                &lt;input id="CheckBox" type="checkbox" formNameArray="Categories" [value]='cat.CategoryID' checked='false'&gt;&lt;/span&gt; {{cat.CategoryName}}
            &lt;/li&gt;
          &lt;/ul&gt;
      &lt;input type="submit" name="btnSubmit" value="Save" id="btnSubmit" (click)="onSubmitedForm()" class="btn btn-primary"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Below is new-post.component.ts file:</p>
  
  <pre><code>export class NewPostComponent implements OnInit {
    public catsList: any = [];
    public newPostDTO: any = [];
    newPostForm: FormGroup;
  
    constructor(private _postsSvc: PostsService,
      private _categoriesSvc: CategoriesService,
      private _formGroup: FormBuilder) { }
  
    ngOnInit() {
      this.getAllCategories();
      this.initProperties(); //init all props
      this.createPostForm(); 
    }
  
  
    initProperties() {
      this.newPostDTO = {
        Title: null,
        Content: null,
        Categories: null
      };
    }
  
    createPostForm() {
      this.newPostForm = this._formGroup.group({
        Title: [''],
        Categories: new FormArray([])
      });
    }
  
    onSubmitedForm() {
      console.log(this.newPostForm.value.Categories);
      this.newPostDTO = {
        Title: this.newPostForm.value.Title,
        Categories:  this.newPostForm.value.Categories,
      };
      this._postsSvc.addPost(this.newPostDTO).subscribe(data =&gt; {
        if (data.status === 201) {
  
        }
      });
    }
  
  
  getAllCategories() {
    this._categoriesSvc.getCategories().subscribe(
      data =&gt; this.catsList = data.body );
    }
  </code></pre>
  
  <p>}
  I want to get all Ids of checked categories as an array when click on submit button. How can I achieve this? 
  I tried but the value of Categories array is null after i CLICK SUBMIT button.</p>
  
  <p>Thank  you to all!</p>