私は確認できるチェックボックスを持っています。だから彼らがアラートに同意すると、すべての演習が完了するようになります。チェックボックスをオンにすると、一度だけ警告が表示されます。
問題:私は、ローカルストレージアイテムdidAllExercises
を設定し、私はアプリを再度開いたとき、私はこのアイテムを取得し、これをtrueにチェックボックスを設定するよりも、本当ですが、私は私のチェックボックスを(onChange) event
を持っているし、チェックボックスがチェックされているか確認してください警告を表示するよりも。私はdidAllExercises
のアプリとアイテムを再度開くときにアラートが毎回を示しここで真
あるチェックボックスです:<ion-checkbox checked="false" [(ngModel)]="cheatCheckbox" (ionChange)="cheatButton(cheatCheckbox)"></ion-checkbox>
そして、これは私のcheatButton()
です:
cheatButton(cheatCheckbox: boolean){
if(cheatCheckbox){
localForage.setItem("showAlert", true);
console.log('ccTrue', cheatCheckbox);
//DONT SHOW ALERT WHEN ALLEX ARE DONE AND YOU CLOSE AND OPENS THE APP AGAIN AND NAVIGATE TO OEFENINGEN
setTimeout(() => {
localForage.getItem("showAlert", (err, value) => {
if(value){
this.showAlert = value;
console.log('!notRun', value);
}
})
},400)
setTimeout(() => {
let alert = this.alertCtrl.create({
title: 'Voltooi alle oefeninen',
message: 'Weet je zeker dat je alle oefeningen gedaan hebt?',
buttons: [
{
text: 'Nee',
role: 'cancel',
handler:() => {
console.log('Cancel clicked');
this.cheatCheckbox = false;
}
},
{
text: 'Ja ik weet het zeker!',
handler:() => {
this.allExercisesDone = true;
localForage.setItem('didAllExercises', [true, this.data]);
}
}
]
});
alert.present();
},400)
}
}
そして、ここで私はgetItem method
を呼び出しますin ionViewWillEnter
:
localForage.getItem('didAllExercises', (err, value) => {
if(value){
this.cheatCheckbox = true;
}
})
この問題を解決するにはどうすればよいですか一度あなたがそれをクリックし、アプリを再び開くよりも、この同じアラートを表示せずにチェックボックスをtrueに設定しますか?
'localForage.getItem'の' this.cheatCheckbox = true;を設定すると 'cheatButton'関数がトリガされますか? – Ari
@Ari yes 'cheatButton'関数はtrueのチェックボックスでトリガーされます – Sreinieren