mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
docs(demos): close popup, actionSheet, modal when page leaves
Closes #311
This commit is contained in:
@ -65,4 +65,11 @@ export class ActionSheetPage {
|
||||
});
|
||||
}
|
||||
|
||||
onPageWillLeave() {
|
||||
let actionSheet = this.actionSheet.get();
|
||||
if (actionSheet) {
|
||||
actionSheet.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,14 @@ class ModalsContentPage {
|
||||
template: '<ion-nav [root]="rootView"></ion-nav>'
|
||||
})
|
||||
export class ModalsPage {
|
||||
constructor() {
|
||||
constructor(modal: Modal) {
|
||||
this.rootView = ModalsFirstPage;
|
||||
this.modal = modal;
|
||||
}
|
||||
onPageWillLeave() {
|
||||
let modal = this.modal.get();
|
||||
if (modal) {
|
||||
modal.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ export class PopupsPage {
|
||||
|
||||
doAlert() {
|
||||
this.popup.alert({
|
||||
title: "New Friend!",
|
||||
template: "Your friend, Obi wan Kenobi, just accepted your friend request!",
|
||||
cssClass: 'my-alert'
|
||||
title: "New Friend!",
|
||||
template: "Your friend, Obi wan Kenobi, just accepted your friend request!",
|
||||
cssClass: 'my-alert'
|
||||
});
|
||||
}
|
||||
|
||||
@ -39,4 +39,13 @@ export class PopupsPage {
|
||||
okText: "Agree"
|
||||
});
|
||||
}
|
||||
|
||||
onPageWillLeave() {
|
||||
let popup = this.popup.get();
|
||||
// only try to close if there is an active popup
|
||||
if (popup) {
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user