I store true checkbox values in an array,
then after getting the array I want to chanage the checkbox isChecked to true if the checkbox value was in the array,
here is the function :
put(array, checkbox){
for(let ent of checkbox) {
for(let entery of array) {
ent.val === entery
? ent.isChecked= true
: ent.isChecked= false
}
}
}
here how did I store checkbox :
public home_category = [
{ val: '???? ???', isChecked: false },
{ val: '????', isChecked: false },
{ val: '???', isChecked: false },
{ val: '????', isChecked: false },
{ val: '???? ????', isChecked: false },
{ val: '????', isChecked: false },
{ val: '???? ?????', isChecked: false },
{ val: '???? ????', isChecked: false },
{ val: '??????', isChecked: false }
];
this function did not work :(
html :
<ion-list>
<ion-item *ngFor="let entry of home_category">
<ion-label>{{entry.val}}</ion-label>
<ion-checkbox slot="end" [(ngModel)]="entry.isChecked"></ion-checkbox>
</ion-item>
</ion-list>
question from:
https://stackoverflow.com/questions/65713710/check-array-values-and-change-input-ischeck-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…