title: Get value from all checked checkbox in angular
body: <p>i'm creating quiz app using angular and i have code like this</p>
  <pre><code>  ngOnInit() {
      this.myForm = this.fb.group({
        lessonCode: &quot;test&quot;,
        answer: this.fb.array([])
      });
    }
    
    onChange(email: string, code: string, isChecked: boolean) {
      const emailFormArray = &lt;FormArray&gt;this.myForm.controls.answer;
  
      if (isChecked) {
        let array = new FormGroup({
          questionCode: new FormControl(email),
          emailCode: new FormArray([
            new FormControl(code)
          ]),
        });
        emailFormArray.push(array);
      } else {
        let index = emailFormArray.controls.findIndex(x =&gt; x.value == email);
        emailFormArray.removeAt(index);
      }
    }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/PGCyo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PGCyo.png" alt="enter image description here" /></a></p>
  <p>which producing array like this</p>
  <pre><code>Form values: {
    &quot;lessonCode&quot;: &quot;test&quot;,
    &quot;answer&quot;: [
      {
        &quot;questionCode&quot;: &quot;pertanyaan2&quot;,
        &quot;emailCode&quot;: [
          &quot;option2&quot;
        ]
      },
      {
        &quot;questionCode&quot;: &quot;pertanyaan2&quot;,
        &quot;emailCode&quot;: [
          &quot;option1&quot;
        ]
      }
    ]
  }
  </code></pre>
  <p>but what i'm actually needed is like this</p>
  <pre><code>Form values: {
    &quot;lessonCode&quot;: &quot;test&quot;,
    &quot;answer&quot;: [
      {
        &quot;questionCode&quot;: &quot;pertanyaan2&quot;,
        &quot;emailCode&quot;: {
          &quot;option2&quot;,
          &quot;option1&quot;
        }
      }
    ]
  }
  </code></pre>
  <p>how can i achieve that? any thoughts would be very helpful</p>
  <p>i have minimal reproduce here <a href="https://stackblitz.com/edit/angular-ca1jin?file=src%2Fapp%2Fapp.component.ts" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-ca1jin?file=src%2Fapp%2Fapp.component.ts</a></p>