docs(demos): close popup, actionSheet, modal when page leaves

Closes #311
This commit is contained in:
Drew Rygh
2015-10-21 16:51:11 -05:00
parent 7f2ac37657
commit 7b13051a52
3 changed files with 27 additions and 4 deletions

View File

@ -65,4 +65,11 @@ export class ActionSheetPage {
}); });
} }
onPageWillLeave() {
let actionSheet = this.actionSheet.get();
if (actionSheet) {
actionSheet.close();
}
}
} }

View File

@ -50,7 +50,14 @@ class ModalsContentPage {
template: '<ion-nav [root]="rootView"></ion-nav>' template: '<ion-nav [root]="rootView"></ion-nav>'
}) })
export class ModalsPage { export class ModalsPage {
constructor() { constructor(modal: Modal) {
this.rootView = ModalsFirstPage; this.rootView = ModalsFirstPage;
this.modal = modal;
}
onPageWillLeave() {
let modal = this.modal.get();
if (modal) {
modal.close();
}
} }
} }

View File

@ -15,9 +15,9 @@ export class PopupsPage {
doAlert() { doAlert() {
this.popup.alert({ this.popup.alert({
title: "New Friend!", title: "New Friend!",
template: "Your friend, Obi wan Kenobi, just accepted your friend request!", template: "Your friend, Obi wan Kenobi, just accepted your friend request!",
cssClass: 'my-alert' cssClass: 'my-alert'
}); });
} }
@ -39,4 +39,13 @@ export class PopupsPage {
okText: "Agree" okText: "Agree"
}); });
} }
onPageWillLeave() {
let popup = this.popup.get();
// only try to close if there is an active popup
if (popup) {
popup.close();
}
}
} }