diff --git a/src/components/modal/modal-component.ts b/src/components/modal/modal-component.ts index 5eb9227d49..f87b158f5c 100644 --- a/src/components/modal/modal-component.ts +++ b/src/components/modal/modal-component.ts @@ -54,34 +54,32 @@ export class ModalCmp { } ionViewPreLoad() { - this._load(this._navParams.data.component); - } - - /** @hidden */ - _load(component: any) { - if (component) { - - let cfr = this.moduleLoader.getComponentFactoryResolver(component); - if (!cfr) { - cfr = this._cfr; - } - const componentFactory = cfr.resolveComponentFactory(component); - - // ******** DOM WRITE **************** - const componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []); - - this._setCssClass(componentRef, 'ion-page'); - this._setCssClass(componentRef, 'show-page'); - - // 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; + const component = this._navParams.data.component; + if (!component) { + console.warn('modal\'s page was not defined'); + return; } + + let cfr = this.moduleLoader.getComponentFactoryResolver(component); + if (!cfr) { + cfr = this._cfr; + } + const componentFactory = cfr.resolveComponentFactory(component); + + // ******** DOM WRITE **************** + const componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []); + + this._setCssClass(componentRef, 'ion-page'); + this._setCssClass(componentRef, 'show-page'); + + // 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; } _viewWillEnter() { @@ -92,7 +90,6 @@ export class ModalCmp { this._gestureBlocker.unblock(); } - /** @hidden */ _setCssClass(componentRef: any, className: string) { this._renderer.setElementClass(componentRef.location.nativeElement, className, true); }