@@ -6,9 +6,9 @@ import {Modal, ActionSheet, NavController, NavParams, Transition, TransitionOpti
66 templateUrl : 'main.html'
77} )
88class E2EPage {
9+ platforms ;
910
10- constructor ( nav : NavController , config : Config , platform : Platform ) {
11- this . nav = nav ;
11+ constructor ( private nav : NavController , config : Config , platform : Platform ) {
1212 console . log ( 'platforms' , platform . platforms ( ) ) ;
1313 console . log ( 'mode' , config . get ( 'mode' ) ) ;
1414
@@ -55,6 +55,14 @@ class E2EPage {
5555 } ) ;
5656 }
5757
58+ presentModalWithInputs ( ) {
59+ let modal = Modal . create ( ModalWithInputs ) ;
60+ modal . onDismiss ( ( data ) => {
61+ console . log ( 'Modal with inputs data:' , data ) ;
62+ } ) ;
63+ this . nav . present ( modal ) ;
64+ }
65+
5866 presentModalCustomAnimation ( ) {
5967 let modal = Modal . create ( ContactUs ) ;
6068 this . nav . present ( modal , {
@@ -85,12 +93,13 @@ class E2EPage {
8593 `
8694} )
8795class ModalPassData {
88- constructor ( params : NavParams , viewCtrl : ViewController ) {
96+ data ;
97+
98+ constructor ( params : NavParams , private viewCtrl : ViewController ) {
8999 this . data = {
90100 userId : params . get ( 'userId' ) ,
91101 name : 'Jenny'
92102 } ;
93- this . viewCtrl = viewCtrl ;
94103 }
95104
96105 submit ( ) {
@@ -118,9 +127,7 @@ class ModalPassData {
118127} )
119128class ToolbarModal {
120129
121- constructor ( viewCtrl : ViewController ) {
122- this . viewCtrl = viewCtrl ;
123- }
130+ constructor ( private viewCtrl : ViewController ) { }
124131
125132 dismiss ( ) {
126133 this . viewCtrl . emit ( {
@@ -133,12 +140,66 @@ class ToolbarModal {
133140
134141
135142@Page ( {
136- template : '<ion-nav [root]="rootView"></ion-nav>'
143+ template : `
144+ <ion-toolbar secondary>
145+ <ion-buttons start>
146+ <button (click)="dismiss()">Close</button>
147+ </ion-buttons>
148+ <ion-title>Modal w/ Inputs</ion-title>
149+ </ion-toolbar>
150+ <ion-content>
151+ <form #addForm="ngForm" (submit)="save($event)" novalidate>
152+ <ion-list>
153+ <ion-item>
154+ <ion-label floating>Title <span [hidden]="title.valid">(Required)</span></ion-label>
155+ <ion-input ngControl="title" type="text" [(ngModel)]="data.title" #title="ngForm" required autofocus></ion-input>
156+ </ion-item>
157+ <ion-item>
158+ <ion-label floating>Note <span [hidden]="note.valid">(Required)</span></ion-label>
159+ <ion-input ngControl="note" type="text" [(ngModel)]="data.note" #note="ngForm" required></ion-input>
160+ </ion-item>
161+ <ion-item>
162+ <ion-label floating>Icon</ion-label>
163+ <ion-input ngControl="icon" type="text" [(ngModel)]="data.icon" #icon="ngForm" autocomplete="on" autocorrect="on"></ion-input>
164+ </ion-item>
165+ </ion-list>
166+ <div padding>
167+ <button block large type="submit" [disabled]="!addForm.valid">Save</button>
168+ </div>
169+ </form>
170+ </ion-content>
171+ `
172+ } )
173+ class ModalWithInputs {
174+ data ;
175+
176+ constructor ( private viewCtrl : ViewController ) {
177+ this . data = {
178+ title : 'Title' ,
179+ note : 'Note' ,
180+ icon : 'home'
181+ } ;
182+ }
183+
184+ public save ( ev ) {
185+ this . viewCtrl . dismiss ( this . data ) ;
186+ }
187+
188+ public dismiss ( ) {
189+ this . viewCtrl . dismiss ( null ) ;
190+ }
191+ }
192+
193+
194+ @Page ( {
195+ template : '<ion-nav [root]="root"></ion-nav>'
137196} )
138197class ContactUs {
198+ root ;
199+
139200 constructor ( ) {
140201 console . log ( 'ContactUs constructor' ) ;
141- this . rootView = ModalFirstPage ;
202+ this . root = ModalFirstPage ;
142203 }
143204 onPageLoaded ( ) {
144205 console . log ( 'ContactUs onPageLoaded' ) ;
@@ -185,9 +246,7 @@ class ContactUs {
185246 `
186247} )
187248class ModalFirstPage {
188- constructor ( nav : NavController ) {
189- this . nav = nav ;
190- }
249+ constructor ( private nav : NavController ) { }
191250
192251 push ( ) {
193252 let page = ModalSecondPage ;
@@ -265,10 +324,9 @@ class ModalFirstPage {
265324} )
266325class ModalSecondPage {
267326 constructor (
268- nav : NavController ,
327+ private nav : NavController ,
269328 params : NavParams
270329 ) {
271- this . nav = nav ;
272330 console . log ( 'Second page params:' , params ) ;
273331 }
274332}
@@ -278,6 +336,8 @@ class ModalSecondPage {
278336 template : '<ion-nav [root]="root"></ion-nav>'
279337} )
280338class E2EApp {
339+ root ;
340+
281341 constructor ( ) {
282342 this . root = E2EPage ;
283343 }
0 commit comments