Reputation: 525
i Am getting the value check in console but the checkbox is not showing checked.
the code and console is given below
<input type = "checkbox" (click)="selectCutype('single',cutType.id)" id="cutType{{cutType.attribute_value}}" (change)="changeCheckbox(i)" >
{{cutType.attribute_value}}
this.array = self.fifthSector.attribute_value_id.split(',');
console.log('array',this.array)this.array.forEach((elem1, index) => {elem1;
console.log(elem1)
res[0].cut_type_sub.forEach((elem2, index) => {elem2;
console.log(elem2.id)
if(elem1 == elem2.id)
{
//--If elem1 equal elem2
this.fish_cuttype[index].checked = !this.fish_cuttype[index].checked;
console.log('Done',elem1 == elem2.id,this.fish_cuttype[index])
}
});
Upvotes: 0
Views: 676
Reputation: 41387
use the [(ngModel)]
with the checked
attribute
<input type = "checkbox" [(ngModel)]="cutType.checked" (click)="selectCutype('single',cutType.id)" id="cutType{{cutType.attribute_value}}" (change)="changeCheckbox(i)" >
Upvotes: 2