docs(modal): example of modals and NavParams

This commit is contained in:
Adam Bradley
2016-02-05 10:45:02 -06:00
parent 729fa9c773
commit 702daa5686

View File

@ -18,14 +18,16 @@ import {Animation} from '../../animations/animation';
* modal can later be closed or "dismissed" by using the ViewController's * modal can later be closed or "dismissed" by using the ViewController's
* `dismiss` method. Additionally, you can dismiss any overlay by using `pop` * `dismiss` method. Additionally, you can dismiss any overlay by using `pop`
* on the root nav controller. * on the root nav controller.
* *
* Data can be passed in through the Modal.Create() function as a second argument. * Data can be passed to a new modal through `Modal.create()` as the second
* This data is available in the modal on the ViewController object as the parameter * argument. The data can gen be accessed from the opened page by injecting
* "data". * `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 * * @usage
* ```ts * ```ts
* import {Modal, NavController, ViewController} from 'ionic/ionic'; * import {Modal, NavController, NavParams} from 'ionic/ionic';
* *
* @Page(...) * @Page(...)
* class HomePage { * class HomePage {
@ -44,22 +46,12 @@ import {Animation} from '../../animations/animation';
* @Page(...) * @Page(...)
* class Profile { * class Profile {
* *
* constructor(viewCtrl: ViewController) { * constructor(params: NavParams) {
* this.viewCtrl = viewCtrl; * console.log('UserId', params.get('userId'));
* }
*
* 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 * 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, * data. For example, a profile page could slide up in a modal, and on submit,