ionic3更新复选框事件值

时间:2017-07-13 21:50:35

标签: ionic3

我试图弄清楚当用户点击它时是否选中了复选框。

下面是代码

 <ion-item-group>
                  <ion-item-divider color="light"><ion-icon name="warning" style="color:#FFBA55"></ion-icon>&nbsp;Overdue Tasks</ion-item-divider>
                  <ion-item> <ion-label class="label-style">item 1</ion-label>
                              <ion-checkbox (ionChange)="updateToDo($event)"></ion-checkbox></ion-item>
                  <ion-item> <ion-label class="label-style">item 2</ion-label>
                              <ion-checkbox (ionChange)="updateToDo($event)"></ion-checkbox></ion-item>

                </ion-item-group>

updateTodo看起来像:

updateToDo(event){

    alert(event.target.checked)
  }

但是这会对事件上的目标属性抛出未定义的操作。

1 个答案:

答案 0 :(得分:1)

我认为checked是传递给函数的事件的属性。

您只需使用event.checked代替event.target.checked