ionic3更新复选框事件值
ionic3 update checkbox event value
我正在尝试确定当用户单击某个复选框时是否选中它。
下面是代码
<ion-item-group>
<ion-item-divider color="light"><ion-icon name="warning" style="color:#FFBA55"></ion-icon> 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)
}
但这会在事件上为目标 属性 抛出未定义的操作。
我认为checked
是一个属性的事件传递给函数。
您可以简单地使用 event.checked
而不是 event.target.checked
。
我正在尝试确定当用户单击某个复选框时是否选中它。
下面是代码
<ion-item-group>
<ion-item-divider color="light"><ion-icon name="warning" style="color:#FFBA55"></ion-icon> 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)
}
但这会在事件上为目标 属性 抛出未定义的操作。
我认为checked
是一个属性的事件传递给函数。
您可以简单地使用 event.checked
而不是 event.target.checked
。