fix(modal): fix onPageWillEnter

Closes #6597
This commit is contained in:
Adam Bradley
2016-05-20 22:07:38 -05:00
parent 6592981aac
commit 01110af12e

View File

@ -107,8 +107,8 @@ import {Transition, TransitionOptions} from '../../transitions/transition';
export class Modal extends ViewController { export class Modal extends ViewController {
constructor(componentType, data: any = {}) { constructor(componentType, data: any = {}) {
data.componentToPresent = componentType; data.componentType = componentType;
super(ModalComponent, data); super(ModalCmp, data);
this.viewType = 'modal'; this.viewType = 'modal';
this.isOverlay = true; this.isOverlay = true;
} }
@ -133,25 +133,24 @@ export class Modal extends ViewController {
@Component({ @Component({
selector: 'ion-modal', selector: 'ion-modal',
template: ` template:
<div class="backdrop"></div> '<div class="backdrop"></div>' +
<div class="modal-wrapper"> '<div class="modal-wrapper">' +
<div #wrapper></div> '<div #viewport></div>' +
</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) {}
}
ngAfterViewInit() { onPageWillEnter() {
let component = this._navParams.data.componentToPresent; this._loader.loadNextToLocation(this._navParams.data.componentType, this.viewport).then(componentRef => {
this._loader.loadNextToLocation(component, this.wrapper).then(componentInstance => { this._viewCtrl.setInstance(componentRef.instance);
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();
}); });
} }
} }