Skip to content

Commit 729fa9c

Browse files
committed
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.
1 parent 687a17b commit 729fa9c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

ionic/components/modal/modal.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,48 @@ import {Animation} from '../../animations/animation';
1818
* modal can later be closed or "dismissed" by using the ViewController's
1919
* `dismiss` method. Additionally, you can dismiss any overlay by using `pop`
2020
* on the root nav controller.
21+
*
22+
* Data can be passed in through the Modal.Create() function as a second argument.
23+
* This data is available in the modal on the ViewController object as the parameter
24+
* "data".
25+
*
26+
* * @usage
27+
* ```ts
28+
* import {Modal, NavController, ViewController} from 'ionic/ionic';
29+
*
30+
* @Page(...)
31+
* class HomePage {
32+
*
33+
* constructor(nav: NavController) {
34+
* this.nav = nav;
35+
* }
36+
*
37+
* presentProfileModal() {
38+
* let profileModal = Modal.create(Profile, { userId: 8675309 });
39+
* this.nav.present(profileModal);
40+
* }
41+
*
42+
* }
43+
*
44+
* @Page(...)
45+
* class Profile {
46+
*
47+
* constructor(viewCtrl: ViewController) {
48+
* this.viewCtrl = viewCtrl;
49+
* }
50+
*
51+
* grabData() {
52+
* let passedData = this.viewCtrl.data;
53+
* }
54+
*
55+
* dismiss() {
56+
* this.viewCtrl.dismiss();
57+
* }
58+
*
59+
* }
60+
* ```
61+
*
62+
*
2163
*
2264
* A modal can also emit data, which is useful when it is used to add or edit
2365
* data. For example, a profile page could slide up in a modal, and on submit,

0 commit comments

Comments
 (0)