Skip to content

Commit 01110af

Browse files
committed
fix(modal): fix onPageWillEnter
Closes #6597
1 parent 6592981 commit 01110af

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/components/modal/modal.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ import {Transition, TransitionOptions} from '../../transitions/transition';
107107
export class Modal extends ViewController {
108108

109109
constructor(componentType, data: any = {}) {
110-
data.componentToPresent = componentType;
111-
super(ModalComponent, data);
110+
data.componentType = componentType;
111+
super(ModalCmp, data);
112112
this.viewType = 'modal';
113113
this.isOverlay = true;
114114
}
@@ -133,25 +133,24 @@ export class Modal extends ViewController {
133133

134134
@Component({
135135
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>'
142141
})
143-
class ModalComponent {
142+
class ModalCmp {
144143

145-
@ViewChild('wrapper', {read: ViewContainerRef}) wrapper: ViewContainerRef;
144+
@ViewChild('viewport', {read: ViewContainerRef}) viewport: ViewContainerRef;
146145

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);
149151

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();
155154
});
156155
}
157156
}

0 commit comments

Comments
 (0)