我正在尝试将数据绑定到ionic复选框,并且在使复选框处于选中状态/未选中状态取决于值时出现问题。我尝试如下所示
<ion-row *ngFor="let well of Wells"
<ion-label>{{well.StateDelivery}}</ion-label>
<ion-checkbox [(ngModel)]="well.StateDelivery" checked='{{getChecked(well.StateDelivery)}}'></ion-checkbox>
</ion-row>
export class Well {
constructor() {
Wells = [
{
"ID": "1",
"StateDelivery": "Y"
},
{
"ID": "2",
"StateDelivery": "N"
},
{
"ID": "3",
"StateDelivery": "Y"
}
]
}
async getChecked(d) {
console.log("#####" + d);
if (d == 'Y') {
return true;
}
else {
return false;
}
}
}