Adi*_*tya 0 typescript ionic-framework ion-toggle ionic2 ionic3
当切换按钮"打开"时,请参阅下面的函数buttonOn(),

我想在buttonOff()"关闭"时切换它,如下所示
html的
<ion-toggle (ionChange)="buttonOn()"></ion-toggle>
Run Code Online (Sandbox Code Playgroud)
.TS
buttonOn() {
// this function is called;
}
buttonOff() {
// how to call this function when toggle button gets off?
}
Run Code Online (Sandbox Code Playgroud)
小智 5
让我们ngModel用来绑定你的toggle的状态,然后调用函数取决于状态
html的
<ion-toggle [(ngModel)]="status" (ionChange)="onChange()"></ion-toggle>
Run Code Online (Sandbox Code Playgroud)
.TS
status=true;
onChange(){
if(this.status){
this.buttonOn();
}
else{
this.buttonOff()
}
}
buttonOn() {
// this function is called;
}
buttonOff() {
// how to call this function when toggle button gets off?
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
563 次 |
| 最近记录: |