离子复选框动态数据绑定

时间:2018-12-13 21:13:13

标签: angularjs typescript ionic-framework

我正在尝试将数据绑定到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;
    }
  }

}

0 个答案:

没有答案