I have a for
that goes over elements in a array of Boolean variables and uses each Boolean as a model for a checkbox.
The models
array looks like this:
models = [true,false,true,true,false,false,true];
The template looks like this:
<h1>Hello {{name}}</h1><br>
<div *ngFor="let mod of models; let i=index">
<input [(ngModel)]="models[i]" type="checkbox">
</div>
<pre>{{models|json}}</pre>
When I click a checkbox, a random element changes its state too. Not sure if this is a bug or I'm just not understanding something.
How do I make this checkboxes behave appropriately?
Complete example showing this behavior: https://plnkr.co/edit/siTXHoIF3OuXnZd37yir?p=preview