title: Storing array of values from checkbox and input elements in Angular+Typescript
body: <p><a href="https://i.stack.imgur.com/W0tEj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W0tEj.png" alt="image"></a>In ref to this question <a href="https://stackoverflow.com/questions/57707339/how-to-dynamically-use-ng-for-to-get-input-boxes-and-checkbox/57707843?noredirect=1#comment101860409_57707843">  https://stackoverflow.com/questions/57707339/how-to-dynamically-use-ng-for-to-get-input-boxes-and-checkbox/57707843?noredirect=1#comment101860409_57707843
  </a>. I am able to dynamically generate div elements(comprises of input element and checkbox). </p>
  
  <p>I am able to retrieve the values. But my problem is: input elements must be stored along with checkboxes that are clicked. Account(input elements) have different roles associated with them. Roles are assigned based on the checkboxes checked values.</p>
  
  <p>In typescript, I want to store account and its roles together. In Angular code,  If I have two accounts, I am able to fetch the values of first account values and not the second value. How to I modify <code>ngFor</code> to fetch multiple accounts values.</p>
  
  <p>Here is the code snippet and what I have tried</p>
  
  <p><strong>Angular.html</strong></p>
  
  <pre><code>&lt;form (ngSubmit)="SaveRecord()" #idForm="ngForm"&gt;
  
   &lt;div *ngFor="let item of record.roles;let i=index"&gt;
    &lt;label for="name"&gt;AccountId&lt;/label&gt;
    &lt;input type="text" class="form-control" [(ngModel)]="item.accountid" name="accountid" (change)="updateUser($event.target.value)" required&gt; 
  
   &lt;label&gt;IT Admin&lt;/label&gt;  
   &lt;mat-checkbox [(ngModel)] = "item.ITrole"  id="check2" [checked]="isChecked"  name="ITcheck" (change)="checkBoxClick($event,'IT Admin')"&gt; 
   &lt;/mat-checkbox&gt;
   &lt;/div&gt;
  
  
  </code></pre>
  
  <p><strong>typescript.ts</strong></p>
  
  <pre><code>  record = {firstName:null,lastName:null,emailAddress:null,accountRoles:1,roles:[{accountid:null,role:null}]};             
  SaveRecord(){
     //what should I write here to get input and checkbox values and store them in array
    }
  </code></pre>