From a23d59c41d3946c57c64ac26a05006c8fbf9e0d5 Mon Sep 17 00:00:00 2001 From: Manuel Mtz-Almeida Date: Thu, 20 Apr 2017 00:09:12 +0200 Subject: [PATCH] docs(modal): explain instance migration --- src/components/modal/modal-component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/modal/modal-component.ts b/src/components/modal/modal-component.ts index d9010c8a86..5eb9227d49 100644 --- a/src/components/modal/modal-component.ts +++ b/src/components/modal/modal-component.ts @@ -69,14 +69,18 @@ export class ModalCmp { // ******** DOM WRITE **************** const componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []); - this._viewCtrl._setInstance(componentRef.instance); this._setCssClass(componentRef, 'ion-page'); this._setCssClass(componentRef, 'show-page'); - this._enabled = true; + // Change the viewcontroller's instance to point the user provided page + // Lifecycle events will be sent to the new instance, instead of the modal's component + // we need to manually subscribe to them + this._viewCtrl._setInstance(componentRef.instance); this._viewCtrl.willEnter.subscribe(this._viewWillEnter.bind(this)); this._viewCtrl.didLeave.subscribe(this._viewDidLeave.bind(this)); + + this._enabled = true; } }