From 729fa9c773d5e7b58e1d11a281aa96714d1509e9 Mon Sep 17 00:00:00 2001 From: Justin Willis Date: Thu, 4 Feb 2016 23:16:16 -0600 Subject: [PATCH 1/2] 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, From 702daa56864a8ffc2c1f7a5447a57753c3340cf0 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 5 Feb 2016 10:45:02 -0600 Subject: [PATCH 2/2] docs(modal): example of modals and NavParams --- ionic/components/modal/modal.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/ionic/components/modal/modal.ts b/ionic/components/modal/modal.ts index 7d41fb85f0..3f42d805a2 100644 --- a/ionic/components/modal/modal.ts +++ b/ionic/components/modal/modal.ts @@ -18,14 +18,16 @@ 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". - * + * + * Data can be passed to a new modal through `Modal.create()` as the second + * argument. The data can gen be accessed from the opened page by injecting + * `NavParams`. Note that the page, which opened as a modal, has no special + * "modal" logic within it, but uses `NavParams` no differently than a + * standard page. + * * * @usage * ```ts - * import {Modal, NavController, ViewController} from 'ionic/ionic'; + * import {Modal, NavController, NavParams} from 'ionic/ionic'; * * @Page(...) * class HomePage { @@ -44,22 +46,12 @@ import {Animation} from '../../animations/animation'; * @Page(...) * class Profile { * - * constructor(viewCtrl: ViewController) { - * this.viewCtrl = viewCtrl; - * } - * - * grabData() { - * let passedData = this.viewCtrl.data; - * } - * - * dismiss() { - * this.viewCtrl.dismiss(); + * constructor(params: NavParams) { + * console.log('UserId', params.get('userId')); * } * * } * ``` - * - * * * 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,