Angular 2: Default checked on checkbox in ngFor
Use the checked property instead of ngModel,
<div class="form-group">
<div class="form-check" *ngFor="let tag of tags">
<label class="form-check-label" for="tag{{tag.value}}">
<input
class="form-check-input"
type="checkbox"
id="tag{{tag.value}}"
name="tagOptions"
[checked]="tag.checked">
{{tag.name}}
</label>
</div>
</div>
DEMO
This solved my problem with the checked/unchecked checkboxes, while I still had control over changes in my variables.
HTML
<div class="form-group">
<div class="form-check" *ngFor="let tag of tags; let i = index;">
<label class="form-check-label" for="tag{{tag.value}}">
<input
class="form-check-input"
type="checkbox"
id="tag{{tag.value}}"
name="tagOptions"
(change)="changeCheckbox(i)"
[checked]="tag.checked">
{{tag.name}}
</label>
</div>
.ts
changeCheckbox(tags, i) {
if (tags) {
this.tags[i].checked = !this.tags[i].checked;
}
}