From 729fa9c773d5e7b58e1d11a281aa96714d1509e9 Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Thu, 4 Feb 2016 23:16:16 -0600 Subject: [PATCH] Show how to access data passed into the modal This addition shows how to access the data that is passed into the modal through the Modal.Create() method. --- ionic/components/modal/modal.ts | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ionic/components/modal/modal.ts b/ionic/components/modal/modal.ts index 54d9b54af7..7d41fb85f0 100644 --- a/ionic/components/modal/modal.ts +++ b/ionic/components/modal/modal.ts @@ -18,6 +18,48 @@ import {Animation} from '../../animations/animation'; * modal can later be closed or "dismissed" by using the ViewController's * `dismiss` method. Additionally, you can dismiss any overlay by using `pop` * on the root nav controller. + * + * Data can be passed in through the Modal.Create() function as a second argument. + * This data is available in the modal on the ViewController object as the parameter + * "data". + * + * * @usage + * ```ts + * import {Modal, NavController, ViewController} from 'ionic/ionic'; + * + * @Page(...) + * class HomePage { + * + * constructor(nav: NavController) { + * this.nav = nav; + * } + * + * presentProfileModal() { + * let profileModal = Modal.create(Profile, { userId: 8675309 }); + * this.nav.present(profileModal); + * } + * + * } + * + * @Page(...) + * class Profile { + * + * constructor(viewCtrl: ViewController) { + * this.viewCtrl = viewCtrl; + * } + * + * grabData() { + * let passedData = this.viewCtrl.data; + * } + * + * dismiss() { + * this.viewCtrl.dismiss(); + * } + * + * } + * ``` + * + * * * A modal can also emit data, which is useful when it is used to add or edit * data. For example, a profile page could slide up in a modal, and on submit,