@@ -107,8 +107,8 @@ import {Transition, TransitionOptions} from '../../transitions/transition';
107
107
export class Modal extends ViewController {
108
108
109
109
constructor ( componentType , data : any = { } ) {
110
- data . componentToPresent = componentType ;
111
- super ( ModalComponent , data ) ;
110
+ data . componentType = componentType ;
111
+ super ( ModalCmp , data ) ;
112
112
this . viewType = 'modal' ;
113
113
this . isOverlay = true ;
114
114
}
@@ -133,25 +133,24 @@ export class Modal extends ViewController {
133
133
134
134
@Component ( {
135
135
selector : 'ion-modal' ,
136
- template : `
137
- <div class="backdrop"></div>
138
- <div class="modal-wrapper">
139
- <div #wrapper></div>
140
- </div>
141
- `
136
+ template :
137
+ '<div class="backdrop"></div>' +
138
+ '<div class="modal-wrapper">' +
139
+ '<div #viewport></div>' +
140
+ '</div>'
142
141
} )
143
- class ModalComponent {
142
+ class ModalCmp {
144
143
145
- @ViewChild ( 'wrapper ' , { read : ViewContainerRef } ) wrapper : ViewContainerRef ;
144
+ @ViewChild ( 'viewport ' , { read : ViewContainerRef } ) viewport : ViewContainerRef ;
146
145
147
- constructor ( private _loader : DynamicComponentLoader , private _navParams : NavParams , private _viewCtrl : ViewController ) {
148
- }
146
+ constructor ( private _loader : DynamicComponentLoader , private _navParams : NavParams , private _viewCtrl : ViewController ) { }
147
+
148
+ onPageWillEnter ( ) {
149
+ this . _loader . loadNextToLocation ( this . _navParams . data . componentType , this . viewport ) . then ( componentRef => {
150
+ this . _viewCtrl . setInstance ( componentRef . instance ) ;
149
151
150
- ngAfterViewInit ( ) {
151
- let component = this . _navParams . data . componentToPresent ;
152
- this . _loader . loadNextToLocation ( component , this . wrapper ) . then ( componentInstance => {
153
- this . _viewCtrl . setInstance ( componentInstance . instance ) ;
154
- // TODO - validate what life cycle events aren't call and possibly call them here if needed
152
+ // manually fire onPageWillEnter() since ModalCmp's onPageWillEnter already happened
153
+ this . _viewCtrl . willEnter ( ) ;
155
154
} ) ;
156
155
}
157
156
}
0 commit comments