Skip to content

Commit 9bcaff8

Browse files
spartanace1024brandyscarney
authored andcommitted
docs(modal): include an example demonstrating onWillDismiss (ionic-team#14067)
* Include an example that shows off onWillDismiss - onWillDismiss was never mentioned in documentation but can be very useful for displaying content before animation occurs. Updated to include an example of onWillDismiss. - Added comments above both onDidDismiss and OnWillDismiss to further explain how they work. * docs(modal): update indentation and add bracket
1 parent 78dbeed commit 9bcaff8

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

src/components/modal/modal-controller.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,37 +77,43 @@ import { DeepLinker } from '../../navigation/deep-linker';
7777
* @Component(...)
7878
* class HomePage {
7979
*
80-
* constructor(public modalCtrl: ModalController) {
80+
* constructor(public modalCtrl: ModalController) {
8181
*
82-
* }
83-
*
84-
* presentContactModal() {
85-
* let contactModal = this.modalCtrl.create(ContactUs);
86-
* contactModal.present();
87-
* }
82+
* }
8883
*
89-
* presentProfileModal() {
90-
* let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });
91-
* profileModal.onDidDismiss(data => {
92-
* console.log(data);
93-
* });
94-
* profileModal.present();
95-
* }
84+
* presentContactModal() {
85+
* let contactModal = this.modalCtrl.create(ContactUs);
86+
* contactModal.present();
87+
* }
9688
*
89+
* presentProfileModal() {
90+
* let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });
91+
*
92+
* // fires after dismiss animation finishes
93+
* profileModal.onDidDismiss(data => {
94+
* console.log(data);
95+
* });
96+
*
97+
* // fires before dismiss animation begins
98+
* profileModal.onWillDismiss(data => {
99+
* console.log(data);
100+
* });
101+
*
102+
* profileModal.present();
103+
* }
97104
* }
98105
*
99106
* @Component(...)
100107
* class Profile {
101108
*
102-
* constructor(public viewCtrl: ViewController) {
103-
*
104-
* }
109+
* constructor(public viewCtrl: ViewController) {
105110
*
106-
* dismiss() {
107-
* let data = { 'foo': 'bar' };
108-
* this.viewCtrl.dismiss(data);
109-
* }
111+
* }
110112
*
113+
* dismiss() {
114+
* let data = { 'foo': 'bar' };
115+
* this.viewCtrl.dismiss(data);
116+
* }
111117
* }
112118
* ```
113119
*

0 commit comments

Comments
 (0)