2017-12-09 2 views
1

나는 경보를 통해 경보를 열었습니다. 그러나 관리자를 선택하면 사용자가 관리자를 선택한 후 첫 번째 경고를 닫으려고합니다.Alert in Alert ionic 3

어떻게하면됩니까?

showAlert2(message) 
{ 
let alert = this.alertCtrl.create({ 
    title:'Sign in as', 

    inputs: [ 
    { 
     type:'checkbox', 
     label:'Admin', 
     value:'admin', 
     handler: data => { 
     this.showAlert3('Sign in'); 
     } 
    }, 
    { 
     type:'checkbox', 
     label:'Patient', 
     value:'patient' 
    } 
    ], 

    buttons: [ 
    { 
     text: 'Login', 
     handler: data => { 
     // if the user chooses patient open a page 
     this.navCtrl.push(PMainPage); 
     // if the user chooses admin i want to create an other alert message 
     } 
    } 
    ] 
    }); 

    alert.present(); 
} 

감사합니다.

답변

2

let alert으로 정의한 이후 현재 경고를 alert.dismiss()으로 닫을 수 있습니다.

let alert = this.alertCtrl.create({ 
    title:'Sign in as', 
    inputs: [ 
    { 
     type:'checkbox', 
     label:'Admin', 
     value:'admin', 
     handler: data => { 
     alert.dismiss(); //here dismiss this alert 
     this.showAlert3('Sign in'); 
     } 
    }, 
    { 
     type:'checkbox', 
     label:'Patient', 
     value:'patient' 
    } 
    ], 
});