title: Adding dynamically checked checkboxes values to a list
body: <p>I'm displaying a list of preference as checkboxes, the problem reside in the binding part where i want a list of the ids that were checked.
  my try who does not work:</p>
  
  <pre><code>&lt;div class="checkbox" *ngFor="let preference of preferences"&gt;
  &lt;label&gt;&lt;input type="checkbox" value="{{preference.id}}" (change)="preferencesStates[i]=$event.target.value"&gt;{{preference.label}}&lt;/label&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is how i bring the preferences:</p>
  
  <pre><code>this.reservationService.getPreferences().subscribe(preferences =&gt; {
    if (preferences) {
      JSON.parse(preferences.body).forEach(element =&gt; {
        this.preferences.push(element);
      });
    }
  });
  </code></pre>