Skip to content

Commit

Permalink
fix(modal): fix onPageWillEnter
Browse files Browse the repository at this point in the history
Closes #6597
  • Loading branch information
adamdbradley committed May 21, 2016
1 parent 6592981 commit 01110af
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/components/modal/modal.ts
Expand Up @@ -107,8 +107,8 @@ import {Transition, TransitionOptions} from '../../transitions/transition';
export class Modal extends ViewController {

constructor(componentType, data: any = {}) {
data.componentToPresent = componentType;
super(ModalComponent, data);
data.componentType = componentType;
super(ModalCmp, data);
this.viewType = 'modal';
this.isOverlay = true;
}
Expand All @@ -133,25 +133,24 @@ export class Modal extends ViewController {

@Component({
selector: 'ion-modal',
template: `
<div class="backdrop"></div>
<div class="modal-wrapper">
<div #wrapper></div>
</div>
`
template:
'<div class="backdrop"></div>' +
'<div class="modal-wrapper">' +
'<div #viewport></div>' +
'</div>'
})
class ModalComponent {
class ModalCmp {

@ViewChild('wrapper', {read: ViewContainerRef}) wrapper: ViewContainerRef;
@ViewChild('viewport', {read: ViewContainerRef}) viewport: ViewContainerRef;

constructor(private _loader: DynamicComponentLoader, private _navParams: NavParams, private _viewCtrl: ViewController) {
}
constructor(private _loader: DynamicComponentLoader, private _navParams: NavParams, private _viewCtrl: ViewController) {}

onPageWillEnter() {
this._loader.loadNextToLocation(this._navParams.data.componentType, this.viewport).then(componentRef => {
this._viewCtrl.setInstance(componentRef.instance);

ngAfterViewInit() {
let component = this._navParams.data.componentToPresent;
this._loader.loadNextToLocation(component, this.wrapper).then(componentInstance => {
this._viewCtrl.setInstance(componentInstance.instance);
// TODO - validate what life cycle events aren't call and possibly call them here if needed
// manually fire onPageWillEnter() since ModalCmp's onPageWillEnter already happened
this._viewCtrl.willEnter();
});
}
}
Expand Down

0 comments on commit 01110af

Please sign in to comment.