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.
This commit is contained in:
Justin Willis
2016-02-04 23:16:16 -06:00
parent 687a17bcd2
commit 729fa9c773

View File

@ -19,6 +19,48 @@ import {Animation} from '../../animations/animation';
* `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,
* the submit button could pass the updated profile data, then dismiss the