2017-08-22 23 views
0

我的問題v.simple但我無法找到解決方案。我試圖在提示警報內顯示基本警報以顯示我輸入的結果,但我不知道爲什麼我的應用程序卡住了。當我嘗試在Ionic 2中使用基本警報提示警報時卡住

這是基本的例子對我的代碼和它的卡住時,「重複的電子郵件」警報顯示,當我OK按鈕點擊使用「超時」

let prompt = this.alertCtrl.create({ 
title: 'Replacement Email', 
message: "Please enter your new email", 
inputs: [{ 
    type: 'email', 
name: 'email', 
placeholder: '[email protected]' 
}, 
], 
buttons: [ 
    { 
    text: 'Cancel', 
    handler: data => { 
     console.log('Cancel clicked'); 
    } 
    },{ 
    text: 'Save', 
    handler: data => { 
     if(data.email!=""){ 
     if(data.email==this.userService.email){ 
      let alert = this.alertCtrl.create({ 
       title: "Duplicated email", 
       subTitle: "Please enter new email", 
       buttons: ['OK'] 
      }); 
      alert.present(); 
     } 
     } 
    } 
    } 
] 
}); 
prompt.present(); 
+0

任何控制檯錯誤? – Sampath

+0

@Sampath沒有錯誤,當顯示第二個提醒時,我的應用程序停滯不前 –

回答

0

我解決了這個問題,我不能將其關閉但我認爲這個問題有更好的解決方案

let prompt = this.alertCtrl.create({ 
title: 'Replacement Email', 
message: "Please enter your new email", 
inputs: [{ 
    type: 'email', 
name: 'email', 
placeholder: '[email protected]' 
}, 
], 
buttons: [ 
    { 
    text: 'Cancel', 
    handler: data => { 
     console.log('Cancel clicked'); 
    } 
    },{ 
    text: 'Save', 
    handler: data => { 
     if(data.email!=""){ 
     if(data.email==this.userService.email){ 
      let alert = this.alertCtrl.create({ 
       title: "Duplicated email", 
       subTitle: "Please enter new email", 
       buttons: ['OK'] 
      }); 
      setTimeout(() => { 
       alert.present(); 
      },250); 
     } 
     } 
    } 
    } 
] 
}); 
prompt.present();