我在控制台中获取值检查但未显示复选框。
下面给出了代码和控制台
<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])
}
});
答案 0 :(得分:2)
将[(ngModel)]
与checked
属性
<input type = "checkbox" [(ngModel)]="cutType.checked" (click)="selectCutype('single',cutType.id)" id="cutType{{cutType.attribute_value}}" (change)="changeCheckbox(i)" >